2009-07-31 12:20:51 +02:00
|
|
|
proc setup {} {
|
|
|
|
save_env
|
2010-11-12 23:35:36 +01:00
|
|
|
# NOTE: Changing dir to $SRCDIR is necessary because file locations in the
|
|
|
|
# ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
|
|
|
|
assert_bash_exec {cd $SRCDIR/fixtures/scp}
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
proc teardown {} {
|
2010-11-12 23:35:36 +01:00
|
|
|
assert_bash_exec {cd $TESTDIR}
|
2009-07-31 12:20:51 +02:00
|
|
|
assert_env_unmodified {
|
|
|
|
/BASH_LINENO=/d
|
|
|
|
/BASH_SOURCE=/d
|
|
|
|
/OLDPWD=/d
|
|
|
|
}
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
setup
|
|
|
|
|
|
|
|
|
|
|
|
set test "Tab should complete remote pwd"
|
|
|
|
set host bash_completion
|
|
|
|
|
|
|
|
# Retrieving home directory (host_pwd) from ssh-host `bash_completion'
|
|
|
|
# yields error?
|
|
|
|
if {
|
|
|
|
[catch {
|
|
|
|
exec -- ssh -o "Batchmode yes" -o "ConnectTimeout 1" $host pwd 2>> /dev/null
|
|
|
|
} host_pwd]
|
|
|
|
} {
|
|
|
|
# Yes, retrieving pwd from ssh yields error; reset `host_pwd'
|
|
|
|
# Indicate host pwd is unknown and test is unsupported
|
|
|
|
# NOTE: To support this test, set the hostname "bash_completion"
|
|
|
|
# in `$HOME/.ssh/config' or `/etc/ssh_config'
|
|
|
|
set host_pwd ""
|
|
|
|
unsupported $test
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Try completion
|
|
|
|
set cmd "scp $host:"
|
|
|
|
send "$cmd\t"
|
|
|
|
sync_after_tab
|
|
|
|
expect {
|
|
|
|
-re "^$cmd$host_pwd.*$" { pass "$test" }
|
|
|
|
-re /@ { unresolved "$test at prompt" }
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
|
|
|
set test "Tab should complete known-hosts"
|
|
|
|
|
|
|
|
# Build string list of expected completions
|
|
|
|
# Get hostnames and give them a colon (:) suffix
|
|
|
|
# Hosts `gee' and `hus' are defined in ./fixtures/scp/config
|
2010-09-28 17:59:31 +03:00
|
|
|
# Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts
|
2009-07-31 12:20:51 +02:00
|
|
|
set expected {}
|
|
|
|
foreach host [get_hosts] {
|
|
|
|
lappend expected "$host:"
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2010-09-28 17:59:31 +03:00
|
|
|
lappend expected blah: doo: gee: hus: ike:
|
2009-07-31 12:20:51 +02:00
|
|
|
# Append local filenames
|
2009-12-03 18:44:30 +01:00
|
|
|
lappend expected config known_hosts "spaced\\ \\ conf"
|
2010-11-12 23:35:36 +01:00
|
|
|
assert_complete $expected "scp -F config "
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
|
|
|
set test "-F without space shouldn't error"
|
|
|
|
# Try completion
|
|
|
|
set cmd "scp -F"
|
|
|
|
send "$cmd\t "
|
|
|
|
expect {
|
|
|
|
-re "^${cmd}bash: option requires an argument -- F" { fail "$test" }
|
|
|
|
-re "^$cmd\r\n.*\r\n/@" { pass "$test" }
|
|
|
|
-re /@ { unresolved "$test at prompt" }
|
|
|
|
default { unresolved "$test" }
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
|
|
|
set test "Config file containing space should work"
|
|
|
|
# Build string list of expected completions
|
|
|
|
# Get hostnames and give them a colon (:) suffix
|
|
|
|
set expected {}
|
|
|
|
foreach host [get_hosts] {
|
|
|
|
lappend expected "$host:"
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-07-31 12:20:51 +02:00
|
|
|
# Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf"
|
2010-09-28 17:59:31 +03:00
|
|
|
# Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts
|
|
|
|
lappend expected blah: doo: gee: hus: ike: jar:
|
2009-07-31 12:20:51 +02:00
|
|
|
# Append local filenames
|
2009-12-03 18:44:30 +01:00
|
|
|
lappend expected config known_hosts "spaced\\ \\ conf"
|
2009-10-04 18:14:16 +02:00
|
|
|
set cmd "scp -F 'spaced conf' "
|
|
|
|
send "$cmd\t"
|
|
|
|
expect -ex "$cmd\r\n"
|
2010-10-31 17:51:14 +01:00
|
|
|
if {[match_items [lsort -unique $expected] -bash-sort]} {
|
2009-10-04 18:14:16 +02:00
|
|
|
expect {
|
2010-11-12 23:35:36 +01:00
|
|
|
-re /@ { pass "$test" }
|
2009-10-04 18:14:16 +02:00
|
|
|
-re eof { unresolved "eof" }
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-10-04 18:14:16 +02:00
|
|
|
} else {
|
|
|
|
# Expected failure (known bug) because of bash-4 bug in quoted words:
|
|
|
|
# http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
|
2009-12-05 14:53:47 +01:00
|
|
|
if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"}
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2010-11-12 23:35:36 +01:00
|
|
|
sync_after_int
|
2010-02-02 11:16:29 +02:00
|
|
|
assert_bash_exec {cd "$TESTDIR"}
|
2009-07-31 12:20:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
|
|
|
teardown
|