proc setup {} {
assert_bash_exec {HOME=$TESTDIR}
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
set test "Tab should complete hostnames"
assert_complete [get_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 [get_hosts] {
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
}
}
assert_complete $hosts "xhost $char" $test -expect-cmd-minus "$char"
sync_after_int
set test "Tab should complete hostnames prefixed with +"
# Build string list of hostnames, prefixed with plus (+)
set hosts {}
foreach h [get_hosts] {
lappend hosts "+$h"
}
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 [get_hosts] {
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"
}
}
assert_complete $hosts "xhost +$char" $test -expect-cmd-minus "\+$char"
sync_after_int
set test "Tab should complete hostnames prefixed with -"
# Build string list of hostnames, prefix with minus (-)
set hosts {}
foreach h [get_hosts] {
lappend hosts "-$h"
}
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 [get_hosts] {
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"
}
}
assert_complete $hosts "xhost -$char" $test -expect-cmd-minus "-$char"
sync_after_int
teardown