2009-06-14 13:15:06 +02:00

100 lines
2.2 KiB
Plaintext

proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
setup
set test "Tab should complete hostnames"
# Build string list of hostnames
set hosts {}
foreach h [exec bash -c "compgen -A hostname"] {
lappend hosts $h
}; # foreach
assert_complete $hosts "xhost " $test
sync_after_int
set test "Tab should complete partial hostname"
# Build string list of hostnames, starting with the character of the first hostname
set hosts {}
set char ""
foreach h [exec bash -c "compgen -A hostname"] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
lappend hosts $h
}; # if
}; # foreach
assert_complete $hosts "xhost $char" $test
sync_after_int
set test "Tab should complete hostnames prefixed with +"
# Build string list of hostnames, prefixed with plus (+)
set hosts {}
foreach h [exec bash -c "compgen -A hostname"] {
lappend hosts "+$h"
}; # foreach
assert_complete $hosts "xhost \+" $test
sync_after_int
set test "Tab should complete partial hostname prefixed with +"
# Build string list of hostnames, starting with character of first host.
set hosts {}
foreach h [exec bash -c "compgen -A hostname"] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
lappend hosts "+$h"
}; # if
}; # foreach
assert_complete $hosts "xhost +$char"
sync_after_int
set test "Tab should complete hostnames prefixed with -"
# Build string list of hostnames, prefix with minus (-)
set hosts {}
foreach h [exec bash -c "compgen -A hostname"] {
lappend hosts "-$h"
}; # foreach
assert_complete $hosts "xhost -" $test
sync_after_int
set test "Tab should complete partial hostname prefixed with -"
# Build list of hostnames, starting with character of first host
set hosts {}
foreach h [exec bash -c "compgen -A hostname"] {
if {$char == ""} {set char [string range $h 0 0]}
# Only append hostname if starting with $char
if {[string range $h 0 0] == "$char"} {
lappend hosts "-$h"
}; # if
}; # foreach
assert_complete $hosts "xhost -$char" $test
sync_after_int
teardown