blob: 31ce04fb4d009fc6662a558e9c32a9dd28f170c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified
}; # teardown()
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
}; # foreach
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"
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 hostname if starting with $char
if {$first == $char} {
# Prefix hosts with username 'test@'
lappend hosts "test@$h"
}; # if
}; # if
}; # foreach
assert_complete $hosts "finger test@$char" $test
sync_after_int
teardown
|