(testsuite) Fix ssh test
Fix ssh test "First argument shouldn't complete with commands" if one has hosts starting with "bas" in known hosts. (Alioth #312292)
This commit is contained in:
parent
6663709d76
commit
9b9bbab1ff
@ -52,30 +52,17 @@ sync_after_int
|
||||
|
||||
|
||||
set test "First argument shouldn't complete with commands"
|
||||
# NOTE: This test assumes the machine running this test has a command "bash"
|
||||
# but no host named "bash" ...
|
||||
# NOTE: This test assumes there's a command "bash" and no host named "bash"
|
||||
set cmd "ssh bas"
|
||||
send "$cmd\t"
|
||||
expect -ex "$cmd"
|
||||
expect {
|
||||
-timeout 1
|
||||
# In case multiple commands `bas*' - besides `bash' - are completed
|
||||
-re "^\r\n.*bash.*\r\n/@$cmd$" { fail "$test" }
|
||||
# In case the single command `bash' is completed
|
||||
-re "h $" { fail "$test" }
|
||||
# In case the hostname `bash_completion' is completed.
|
||||
# See `scp' tests in `lib/completions/scp.exp'
|
||||
-re "h_completion $" { pass "$test" }
|
||||
-re ".+" { unresolved "$test" }
|
||||
timeout { pass "$test" }
|
||||
}; # expect
|
||||
assert_complete [get_known_hosts "bas"] $cmd $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "First argument should complete partial hostname"
|
||||
assert_complete_partial [get_hosts] ssh "" $test /@ 20 [list "ltrim_colon_completions"]
|
||||
assert_complete_partial [get_hosts] ssh "" $test /@ 20 \
|
||||
[list "ltrim_colon_completions"]
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
@ -462,10 +462,12 @@ proc bash_sort {items} {
|
||||
|
||||
|
||||
# Get 'known' hostnames. Looks also in ssh's 'known_hosts' files.
|
||||
# @param string cword (optional) Word, hosts should start with.
|
||||
# @return list Hostnames
|
||||
# @see get_hosts()
|
||||
proc get_known_hosts {} {
|
||||
assert_bash_exec {_known_hosts_real ''; echo_array COMPREPLY} {} /@ result
|
||||
proc get_known_hosts {{cword ''}} {
|
||||
assert_bash_exec "_known_hosts_real '$cword'; echo_array COMPREPLY" \
|
||||
{} /@ result
|
||||
return $result
|
||||
}; # get_known_hosts()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user