bash-completion/test/unit/_known_hosts.exp
Freddy Vulto cd2b62bd62 Fix quotes _known_hosts calling _known_hosts_real
This fixes test "Config file containing space should work".  See test:

   ./runUnit _known_hosts.exp
2009-06-11 21:26:43 +02:00

64 lines
1.7 KiB
Plaintext

proc setup {} {
save_env
}; # setup()
proc teardown {} {
assert_env_unmodified {/COMPREPLY=/d}
}; # teardown()
setup
set test "Hosts should be put in COMPREPLY"
# Build string list of hostnames, separated by regexp whitespace marker (\s+).
# Example string: host1\s+host2\s+host3
set hosts [exec bash -c "compgen -A hostname"]
# Hosts `gee' and `hus' are defined in ./fixtures/_known_hosts/config
# Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts/known_hosts
lappend hosts doo gee hus ike
set hosts [lsort -ascii $hosts]
set hosts [join $hosts "\\s+"]
# Call _known_hosts
set cmd {_known_hosts -aF fixtures/_known_hosts/config; echo_array COMPREPLY}
send "$cmd\r"
expect -ex "$cmd\r\n"
expect {
-re "^$hosts\r\n/@$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
default { unresolved "$test" }
}; # expect
sync_after_int
set test "Config file containing space should work"
# Build string list of hostnames, separated by regexp whitespace marker (\s+).
# Example string: host1\s+host2\s+host3
set hosts [exec bash -c "compgen -A hostname"]
# Hosts `gee' and `hus' are defined in ./fixtures/_known_hosts/spaced conf
# Hosts `doo' and `ike' are defined in ./fixtures/_known_hosts/known_hosts
# Host `two' is defined in ./fixtures/_known_hosts/known_hosts2
lappend hosts gee hus doo ike two
set hosts [lsort -ascii $hosts]
set hosts [join $hosts "\\s+"]
# Call _known_hosts
set cmd {_known_hosts -aF 'fixtures/_known_hosts/spaced conf'; echo_array COMPREPLY}
send "$cmd\r"
expect -ex "$cmd\r\n"
expect {
-re "^$hosts\r\n/@$" { pass "$test" }
-re /@ { unresolved "$test at prompt" }
default { unresolved "$test" }
}; # expect
sync_after_int
teardown