2011-06-05 22:06:28 +04:00

58 lines
1.3 KiB
Plaintext

proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
set test "Tab should complete usernames"
# Build string list of usernames
set users {}
foreach u [exec bash -c "compgen -A user"] {
lappend users $u
}
assert_complete $users "finger " $test
sync_after_int
set test "Tab should complete partial username"
assert_complete_partial [exec bash -c "compgen -A user"] "finger" "" $test -nospace
sync_after_int
set test "Tab should complete partial hostname"
# Build string list of hostnames, starting with the character of the first
# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
# Hosts starting with a COMP_WORDBREAKS character are left out because these
# are exceptional cases, requiring specific tests.
set hosts {}
set char ""
foreach h [get_known_hosts] {
set first [string range $h 0 0]
if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
if {$char != ""} {
# Only append unique hostnames starting with $char
if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} {
# Prefix hosts with username 'test@'
lappend hosts "test@$h"
}
}
}
assert_complete $hosts "finger test@$char" $test -expect-cmd-minus "test@$char"
sync_after_int
teardown