diff options
119 files changed, 877 insertions, 910 deletions
diff --git a/test/_completion_to_review/sbcl-mt.exp b/test/_completion_to_review/sbcl-mt.exp deleted file mode 100644 index 393ec0a9..00000000 --- a/test/_completion_to_review/sbcl-mt.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sbcl-mt.exp" diff --git a/test/_completion_to_review/sbcl.exp b/test/_completion_to_review/sbcl.exp deleted file mode 100644 index d4f06979..00000000 --- a/test/_completion_to_review/sbcl.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sbcl.exp" diff --git a/test/_completion_to_review/scp.exp b/test/_completion_to_review/scp.exp deleted file mode 100644 index 11d354ce..00000000 --- a/test/_completion_to_review/scp.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/scp.exp" diff --git a/test/_completion_to_review/screen.exp b/test/_completion_to_review/screen.exp deleted file mode 100644 index dd8f6a18..00000000 --- a/test/_completion_to_review/screen.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/screen.exp" diff --git a/test/_completion_to_review/sed.exp b/test/_completion_to_review/sed.exp deleted file mode 100644 index e67e44e5..00000000 --- a/test/_completion_to_review/sed.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sed.exp" diff --git a/test/_completion_to_review/seq.exp b/test/_completion_to_review/seq.exp deleted file mode 100644 index adcfca92..00000000 --- a/test/_completion_to_review/seq.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/seq.exp" diff --git a/test/_completion_to_review/service.exp b/test/_completion_to_review/service.exp deleted file mode 100644 index 46156ace..00000000 --- a/test/_completion_to_review/service.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/service.exp" diff --git a/test/_completion_to_review/set.exp b/test/_completion_to_review/set.exp deleted file mode 100644 index 5a1b1d05..00000000 --- a/test/_completion_to_review/set.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/set.exp" diff --git a/test/_completion_to_review/sha1sum.exp b/test/_completion_to_review/sha1sum.exp deleted file mode 100644 index 9250b0b4..00000000 --- a/test/_completion_to_review/sha1sum.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sha1sum.exp" diff --git a/test/_completion_to_review/shar.exp b/test/_completion_to_review/shar.exp deleted file mode 100644 index 693fef92..00000000 --- a/test/_completion_to_review/shar.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/shar.exp" diff --git a/test/_completion_to_review/sitecopy.exp b/test/_completion_to_review/sitecopy.exp deleted file mode 100644 index e923dda8..00000000 --- a/test/_completion_to_review/sitecopy.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sitecopy.exp" diff --git a/test/_completion_to_review/snownews.exp b/test/_completion_to_review/snownews.exp deleted file mode 100644 index a12bdfc1..00000000 --- a/test/_completion_to_review/snownews.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/snownews.exp" diff --git a/test/_completion_to_review/sort.exp b/test/_completion_to_review/sort.exp deleted file mode 100644 index 02e9bdd4..00000000 --- a/test/_completion_to_review/sort.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sort.exp" diff --git a/test/_completion_to_review/split.exp b/test/_completion_to_review/split.exp deleted file mode 100644 index 99e0909c..00000000 --- a/test/_completion_to_review/split.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/split.exp" diff --git a/test/_completion_to_review/spovray.exp b/test/_completion_to_review/spovray.exp deleted file mode 100644 index 78e3fd9c..00000000 --- a/test/_completion_to_review/spovray.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/spovray.exp" diff --git a/test/_completion_to_review/ssh.exp b/test/_completion_to_review/ssh.exp deleted file mode 100644 index f38857de..00000000 --- a/test/_completion_to_review/ssh.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/ssh.exp" diff --git a/test/_completion_to_review/sshmitm.exp b/test/_completion_to_review/sshmitm.exp deleted file mode 100644 index 985dbea9..00000000 --- a/test/_completion_to_review/sshmitm.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sshmitm.exp" diff --git a/test/_completion_to_review/sshow.exp b/test/_completion_to_review/sshow.exp deleted file mode 100644 index 6c33d65b..00000000 --- a/test/_completion_to_review/sshow.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sshow.exp" diff --git a/test/_completion_to_review/strip.exp b/test/_completion_to_review/strip.exp deleted file mode 100644 index 29ec81fa..00000000 --- a/test/_completion_to_review/strip.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/strip.exp" diff --git a/test/_completion_to_review/sudo.exp b/test/_completion_to_review/sudo.exp deleted file mode 100644 index 0d1d19e6..00000000 --- a/test/_completion_to_review/sudo.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sudo.exp" diff --git a/test/_completion_to_review/svk.exp b/test/_completion_to_review/svk.exp deleted file mode 100644 index 70b0b1b9..00000000 --- a/test/_completion_to_review/svk.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/svk.exp" diff --git a/test/_completion_to_review/svn.exp b/test/_completion_to_review/svn.exp deleted file mode 100644 index 4252349f..00000000 --- a/test/_completion_to_review/svn.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/svn.exp" diff --git a/test/_completion_to_review/svnadmin.exp b/test/_completion_to_review/svnadmin.exp deleted file mode 100644 index a8790923..00000000 --- a/test/_completion_to_review/svnadmin.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/svnadmin.exp" diff --git a/test/_completion_to_review/svnlook.exp b/test/_completion_to_review/svnlook.exp deleted file mode 100644 index c866811b..00000000 --- a/test/_completion_to_review/svnlook.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/svnlook.exp" diff --git a/test/_completion_to_review/sync_members.exp b/test/_completion_to_review/sync_members.exp deleted file mode 100644 index 30e49fe7..00000000 --- a/test/_completion_to_review/sync_members.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sync_members.exp" diff --git a/test/_completion_to_review/sysctl.exp b/test/_completion_to_review/sysctl.exp deleted file mode 100644 index c1b361a0..00000000 --- a/test/_completion_to_review/sysctl.exp +++ /dev/null @@ -1 +0,0 @@ -source "lib/completions/sysctl.exp" diff --git a/test/completion/sbcl-mt.exp b/test/completion/sbcl-mt.exp new file mode 100644 index 00000000..bea489b5 --- /dev/null +++ b/test/completion/sbcl-mt.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sbcl-mt]} { + source "lib/completions/sbcl-mt.exp" +}; # if diff --git a/test/completion/sbcl.exp b/test/completion/sbcl.exp new file mode 100644 index 00000000..d10c6f82 --- /dev/null +++ b/test/completion/sbcl.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sbcl]} { + source "lib/completions/sbcl.exp" +}; # if diff --git a/test/completion/scp.exp b/test/completion/scp.exp new file mode 100644 index 00000000..d100aa61 --- /dev/null +++ b/test/completion/scp.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type scp]} { + source "lib/completions/scp.exp" +}; # if diff --git a/test/completion/screen.exp b/test/completion/screen.exp new file mode 100644 index 00000000..f6009722 --- /dev/null +++ b/test/completion/screen.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type screen]} { + source "lib/completions/screen.exp" +}; # if diff --git a/test/completion/sed.exp b/test/completion/sed.exp new file mode 100644 index 00000000..8a014614 --- /dev/null +++ b/test/completion/sed.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sed]} { + source "lib/completions/sed.exp" +}; # if diff --git a/test/completion/seq.exp b/test/completion/seq.exp new file mode 100644 index 00000000..4dcd7bb9 --- /dev/null +++ b/test/completion/seq.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type seq]} { + source "lib/completions/seq.exp" +}; # if diff --git a/test/completion/service.exp b/test/completion/service.exp new file mode 100644 index 00000000..b4534233 --- /dev/null +++ b/test/completion/service.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type service]} { + source "lib/completions/service.exp" +}; # if diff --git a/test/completion/set.exp b/test/completion/set.exp new file mode 100644 index 00000000..6a882bd2 --- /dev/null +++ b/test/completion/set.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type set]} { + source "lib/completions/set.exp" +}; # if diff --git a/test/completion/sftp.exp b/test/completion/sftp.exp new file mode 100644 index 00000000..4eb27e7a --- /dev/null +++ b/test/completion/sftp.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sftp]} { + source "lib/completions/sftp.exp" +}; # if diff --git a/test/completion/sha1sum.exp b/test/completion/sha1sum.exp new file mode 100644 index 00000000..46a8e8c5 --- /dev/null +++ b/test/completion/sha1sum.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sha1sum]} { + source "lib/completions/sha1sum.exp" +}; # if diff --git a/test/completion/shar.exp b/test/completion/shar.exp new file mode 100644 index 00000000..1c6adb2a --- /dev/null +++ b/test/completion/shar.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type shar]} { + source "lib/completions/shar.exp" +}; # if diff --git a/test/completion/sitecopy.exp b/test/completion/sitecopy.exp new file mode 100644 index 00000000..8b413593 --- /dev/null +++ b/test/completion/sitecopy.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sitecopy]} { + source "lib/completions/sitecopy.exp" +}; # if diff --git a/test/_completion_to_review/smartctl.exp b/test/completion/smartctl.exp index faae2bc1..faae2bc1 100644 --- a/test/_completion_to_review/smartctl.exp +++ b/test/completion/smartctl.exp diff --git a/test/completion/snownews.exp b/test/completion/snownews.exp new file mode 100644 index 00000000..4ed33e12 --- /dev/null +++ b/test/completion/snownews.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type snownews]} { + source "lib/completions/snownews.exp" +}; # if diff --git a/test/completion/sort.exp b/test/completion/sort.exp new file mode 100644 index 00000000..21c592fd --- /dev/null +++ b/test/completion/sort.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sort]} { + source "lib/completions/sort.exp" +}; # if diff --git a/test/completion/split.exp b/test/completion/split.exp new file mode 100644 index 00000000..fca9bcb0 --- /dev/null +++ b/test/completion/split.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type split]} { + source "lib/completions/split.exp" +}; # if diff --git a/test/completion/spovray.exp b/test/completion/spovray.exp new file mode 100644 index 00000000..cceac7da --- /dev/null +++ b/test/completion/spovray.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type spovray]} { + source "lib/completions/spovray.exp" +}; # if diff --git a/test/completion/ssh.exp b/test/completion/ssh.exp index 5b14ce25..f95761b0 100644 --- a/test/completion/ssh.exp +++ b/test/completion/ssh.exp @@ -1,6 +1,3 @@ -source "lib/completions/ssh.exp" - -# TODO: Dynamic loading of completions. After the tests have the first time and -# real completion is installed, the tests can be run a second time. -# -# source "lib/completions/ssh.exp" +if {[assert_bash_type {ssh}]} { + source "lib/completions/ssh.exp" +}; # if diff --git a/test/completion/sshmitm.exp b/test/completion/sshmitm.exp new file mode 100644 index 00000000..e6dc76a4 --- /dev/null +++ b/test/completion/sshmitm.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sshmitm]} { + source "lib/completions/sshmitm.exp" +}; # if diff --git a/test/completion/sshow.exp b/test/completion/sshow.exp new file mode 100644 index 00000000..b0c68da6 --- /dev/null +++ b/test/completion/sshow.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sshow]} { + source "lib/completions/sshow.exp" +}; # if diff --git a/test/completion/strip.exp b/test/completion/strip.exp new file mode 100644 index 00000000..4ce38360 --- /dev/null +++ b/test/completion/strip.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type strip]} { + source "lib/completions/strip.exp" +}; # if diff --git a/test/completion/sudo.exp b/test/completion/sudo.exp new file mode 100644 index 00000000..d4369ef5 --- /dev/null +++ b/test/completion/sudo.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type {sudo}]} { + source "lib/completions/sudo.exp" +}; # if diff --git a/test/completion/svk.exp b/test/completion/svk.exp new file mode 100644 index 00000000..29058146 --- /dev/null +++ b/test/completion/svk.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type svk]} { + source "lib/completions/svk.exp" +}; # if diff --git a/test/completion/svn.exp b/test/completion/svn.exp new file mode 100644 index 00000000..61aee593 --- /dev/null +++ b/test/completion/svn.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type svn]} { + source "lib/completions/svn.exp" +}; # if diff --git a/test/completion/svnadmin.exp b/test/completion/svnadmin.exp new file mode 100644 index 00000000..83e042a5 --- /dev/null +++ b/test/completion/svnadmin.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type svnadmin]} { + source "lib/completions/svnadmin.exp" +}; # if diff --git a/test/completion/svnlook.exp b/test/completion/svnlook.exp new file mode 100644 index 00000000..1e003e53 --- /dev/null +++ b/test/completion/svnlook.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type svnlook]} { + source "lib/completions/svnlook.exp" +}; # if diff --git a/test/completion/sync_members.exp b/test/completion/sync_members.exp new file mode 100644 index 00000000..23277128 --- /dev/null +++ b/test/completion/sync_members.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sync_members]} { + source "lib/completions/sync_members.exp" +}; # if diff --git a/test/completion/sysctl.exp b/test/completion/sysctl.exp new file mode 100644 index 00000000..debb8d62 --- /dev/null +++ b/test/completion/sysctl.exp @@ -0,0 +1,3 @@ +if {[assert_bash_type sysctl]} { + source "lib/completions/sysctl.exp" +}; # if diff --git a/test/fixtures/scp/config b/test/fixtures/scp/config new file mode 100644 index 00000000..fea6620e --- /dev/null +++ b/test/fixtures/scp/config @@ -0,0 +1,6 @@ +UserKnownHostsFile known_hosts + + # Unindented +Host gee + # Indented, multiple hosts + HostName hus ike diff --git a/test/fixtures/scp/known_hosts b/test/fixtures/scp/known_hosts new file mode 100644 index 00000000..d54a04d0 --- /dev/null +++ b/test/fixtures/scp/known_hosts @@ -0,0 +1,4 @@ +|1|abc +|1|def +doo +ike ssh-rsa qwerty1234/Qwerty+1234== diff --git a/test/fixtures/scp/spaced conf b/test/fixtures/scp/spaced conf new file mode 100644 index 00000000..7ad64bc8 --- /dev/null +++ b/test/fixtures/scp/spaced conf @@ -0,0 +1,6 @@ + UserKnownHostsFile known_hosts + + # Unindented +Host gee jar + # Indented, multiple hosts + HostName hus diff --git a/test/fixtures/sftp/config b/test/fixtures/sftp/config new file mode 100644 index 00000000..fea6620e --- /dev/null +++ b/test/fixtures/sftp/config @@ -0,0 +1,6 @@ +UserKnownHostsFile known_hosts + + # Unindented +Host gee + # Indented, multiple hosts + HostName hus ike diff --git a/test/fixtures/sftp/known_hosts b/test/fixtures/sftp/known_hosts new file mode 100644 index 00000000..d54a04d0 --- /dev/null +++ b/test/fixtures/sftp/known_hosts @@ -0,0 +1,4 @@ +|1|abc +|1|def +doo +ike ssh-rsa qwerty1234/Qwerty+1234== diff --git a/test/fixtures/sftp/spaced conf b/test/fixtures/sftp/spaced conf new file mode 100644 index 00000000..7ad64bc8 --- /dev/null +++ b/test/fixtures/sftp/spaced conf @@ -0,0 +1,6 @@ + UserKnownHostsFile known_hosts + + # Unindented +Host gee jar + # Indented, multiple hosts + HostName hus diff --git a/test/fixtures/ssh/config b/test/fixtures/ssh/config index ab30ce41..806f405c 100644 --- a/test/fixtures/ssh/config +++ b/test/fixtures/ssh/config @@ -1 +1 @@ -UserKnownHostsFile fixtures/ssh/known_hosts +UserKnownHostsFile known_hosts diff --git a/test/fixtures/ssh/spaced conf b/test/fixtures/ssh/spaced conf new file mode 100644 index 00000000..7ad64bc8 --- /dev/null +++ b/test/fixtures/ssh/spaced conf @@ -0,0 +1,6 @@ + UserKnownHostsFile known_hosts + + # Unindented +Host gee jar + # Indented, multiple hosts + HostName hus diff --git a/test/lib/completions/sbcl-mt.exp b/test/lib/completions/sbcl-mt.exp new file mode 100644 index 00000000..905a62ca --- /dev/null +++ b/test/lib/completions/sbcl-mt.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sbcl-mt " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sbcl.exp b/test/lib/completions/sbcl.exp new file mode 100644 index 00000000..27633320 --- /dev/null +++ b/test/lib/completions/sbcl.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sbcl " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp new file mode 100644 index 00000000..d16741a2 --- /dev/null +++ b/test/lib/completions/scp.exp @@ -0,0 +1,104 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified { + /BASH_LINENO=/d + /BASH_SOURCE=/d + /OLDPWD=/d + } +}; # teardown() + + +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 +}; # if + + + # Try completion +set cmd "scp $host:" +send "$cmd\t" +sync_after_tab +expect { + -re "^$cmd$host_pwd.*$" { pass "$test" } + -re /@ { unresolved "$test at prompt" } +}; # expect + + +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 + # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts +set expected {} +foreach host [get_hosts] { + lappend expected "$host:" +}; # foreach +lappend expected doo: gee: hus: ike: + # Append local filenames +lappend expected config known_hosts "spaced\\\\ \\\\ conf" +set dir fixtures/scp +assert_complete_dir $expected "scp -F config " $dir + + +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" } +}; # expect + + +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:" +}; # foreach + # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf" + # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts +lappend expected doo: gee: hus: ike: jar: + # Append local filenames +lappend expected config known_hosts "spaced\\\\ \\\\ conf" +set dir fixtures/scp +assert_complete_dir $expected "scp -F 'spaced conf' " $dir + + +sync_after_int + + +teardown diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp new file mode 100644 index 00000000..5d018714 --- /dev/null +++ b/test/lib/completions/screen.exp @@ -0,0 +1,44 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +}; # teardown() + + +setup + + +assert_complete_any "screen -" + + +sync_after_int + + +set test "-c should complete files/dirs" +set dir fixture1 +set prompt "/$dir/@" +assert_bash_exec "cd $dir" "" $prompt +set cmd "screen -c " +set expected {bar {bar bar.d} foo {foo.d}} +send "$cmd\t" +expect -ex "$cmd" +expect { + -re "bar\\s+bar\\\\ bar.d\\s+foo\\s+foo.d" { pass "$test" } + # _filedir works only if `-o filenames' is in effect, which isn't the + # case for `screen' + -re "bar\\s+bar bar.d\\s+foo\\s+foo.d" { xfail "$test" } + -re $prompt { unresolved "$test at prompt" } + default { unresolved "$test" } +}; # expect +sync_after_int $prompt +assert_bash_exec "cd \$TESTDIR" + + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sed.exp b/test/lib/completions/sed.exp new file mode 100644 index 00000000..05841070 --- /dev/null +++ b/test/lib/completions/sed.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sed --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/seq.exp b/test/lib/completions/seq.exp new file mode 100644 index 00000000..b5333ef9 --- /dev/null +++ b/test/lib/completions/seq.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "seq --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/service.exp b/test/lib/completions/service.exp new file mode 100644 index 00000000..917c5dcb --- /dev/null +++ b/test/lib/completions/service.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "service " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/set.exp b/test/lib/completions/set.exp new file mode 100644 index 00000000..2b2d40e9 --- /dev/null +++ b/test/lib/completions/set.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "set no" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp new file mode 100644 index 00000000..7cd89c0c --- /dev/null +++ b/test/lib/completions/sftp.exp @@ -0,0 +1,77 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified { + /BASH_LINENO=/d + /BASH_SOURCE=/d + /OLDPWD=/d + } +}; # teardown() + + +setup + + + # Build string list of expected completions +set expected [get_hosts] + # Hosts `gee' and `hus' are defined in ./fixtures/sftp/config + # Hosts `doo' and `ike' are defined in ./fixtures/sftp/known_hosts +lappend expected doo gee hus ike +set dir fixtures/scp +assert_complete_dir $expected "sftp -F config " $dir + + +sync_after_int + + +set test "-F without space shouldn't error" + # Try completion +set cmd "sftp -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" } +}; # expect + + +sync_after_int + + + # Build string list of expected completions + # Get hostnames and give them a colon (:) suffix +set expected [get_hosts] + # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf" + # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts +lappend expected doo gee hus ike jar +set dir fixtures/scp +assert_complete_dir $expected "sftp -F 'spaced conf' " $dir + + +sync_after_int + + +set test "-F should complete filename" +set dir fixtures/sftp +set prompt "/$dir/@" +assert_bash_exec "cd $dir" "" $prompt +set cmd "ssh -Fsp" +send "$cmd\t" +expect -ex "$cmd" +expect { + -ex "aced\\ \\ conf" { pass "$test" } + # _filedir works only if `-o filenames' is in effect, which isn't the + # case for `sftp' + -re "aced conf" { xfail "$test" } + -re $prompt { unresolved "$test at prompt" } + default { unresolved "$test" } +}; # expect +sync_after_int $prompt +assert_bash_exec "cd \$TESTDIR" + + +teardown diff --git a/test/lib/completions/sha1sum.exp b/test/lib/completions/sha1sum.exp new file mode 100644 index 00000000..17519087 --- /dev/null +++ b/test/lib/completions/sha1sum.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sha1sum --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/shar.exp b/test/lib/completions/shar.exp new file mode 100644 index 00000000..7ace9d6e --- /dev/null +++ b/test/lib/completions/shar.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "shar --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sitecopy.exp b/test/lib/completions/sitecopy.exp new file mode 100644 index 00000000..49b78918 --- /dev/null +++ b/test/lib/completions/sitecopy.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sitecopy --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smartctl.exp b/test/lib/completions/smartctl.exp new file mode 100644 index 00000000..a9eeb956 --- /dev/null +++ b/test/lib/completions/smartctl.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "smartctl --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/snownews.exp b/test/lib/completions/snownews.exp new file mode 100644 index 00000000..7502e587 --- /dev/null +++ b/test/lib/completions/snownews.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "snownews --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sort.exp b/test/lib/completions/sort.exp new file mode 100644 index 00000000..20516cc8 --- /dev/null +++ b/test/lib/completions/sort.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sort --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/split.exp b/test/lib/completions/split.exp new file mode 100644 index 00000000..249ff9bc --- /dev/null +++ b/test/lib/completions/split.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "split --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/spovray.exp b/test/lib/completions/spovray.exp new file mode 100644 index 00000000..30d81853 --- /dev/null +++ b/test/lib/completions/spovray.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "spovray " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp index 81b88e4b..6afd3397 100644 --- a/test/lib/completions/ssh.exp +++ b/test/lib/completions/ssh.exp @@ -4,23 +4,32 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified { + /BASH_LINENO=/d + /BASH_SOURCE=/d + /OLDPWD=/d + } }; # teardown() setup -set test "Tab should complete both commands and hostnames" +set test "Tab should complete both commands and hostname" # Try completion -set cmd "ssh -F fixtures/ssh/config ls" +set dir fixtures/ssh +set prompt "/$dir/@" +assert_bash_exec "cd $dir" "" $prompt +set cmd "ssh -F config ls" send "$cmd\t" -set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n/@$cmd$" +set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n$prompt$cmd$" expect { -re $expected { pass "$test" } - -re /@ { unresolved "$test at prompt" } + -re $prompt { unresolved "$test at prompt" } default { unresolved "$test" } }; # expect +sync_after_int $prompt +assert_bash_exec "cd \$TESTDIR" sync_after_int @@ -33,7 +42,7 @@ send "$cmd\t " set expected "^$cmd $" expect { -re "^${cmd}bash: option requires an argument -- F" { fail "$test" } - -re $expected { pass "$test" } + -re "^$cmd\r\n.*\r\n/@" { pass "$test" } -re /@ { unresolved "$test at prompt" } default { unresolved "$test" } }; # expect @@ -50,10 +59,13 @@ send "$cmd\t" expect -ex "$cmd" expect { -timeout 1 - # In case multiple commands `bas*' are completed + # 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 @@ -62,8 +74,30 @@ expect { sync_after_int -set test "Tab should complete partial hostname" -assert_complete_partial [get_hosts] "ssh" +set test "First argument should complete partial hostname" +assert_complete_partial [get_hosts] ssh + + +sync_after_int + + +set test "-F should complete filename" +set dir fixtures/ssh +set prompt "/$dir/@" +assert_bash_exec "cd $dir" "" $prompt +set cmd "ssh -Fsp" +send "$cmd\t" +expect -ex "$cmd" +expect { + -ex "aced\\ \\ conf" { pass "$test" } + # _filedir works only if `-o filenames' is in effect, which isn't the + # case for `ssh' + -re "aced conf" { xfail "$test" } + -re $prompt { unresolved "$test at prompt" } + default { unresolved "$test" } +}; # expect +sync_after_int $prompt +assert_bash_exec "cd \$TESTDIR" sync_after_int diff --git a/test/lib/completions/sshmitm.exp b/test/lib/completions/sshmitm.exp new file mode 100644 index 00000000..b8f8a2c9 --- /dev/null +++ b/test/lib/completions/sshmitm.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sshmitm -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sshow.exp b/test/lib/completions/sshow.exp new file mode 100644 index 00000000..36a6cc2c --- /dev/null +++ b/test/lib/completions/sshow.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sshow -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/strip.exp b/test/lib/completions/strip.exp new file mode 100644 index 00000000..46d9f362 --- /dev/null +++ b/test/lib/completions/strip.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "strip --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp new file mode 100644 index 00000000..3dc98da3 --- /dev/null +++ b/test/lib/completions/sudo.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete "fixture1/foo.d/" "sudo cd fixture1/fo" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/svk.exp b/test/lib/completions/svk.exp new file mode 100644 index 00000000..a08674dc --- /dev/null +++ b/test/lib/completions/svk.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "svk " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/svn.exp b/test/lib/completions/svn.exp new file mode 100644 index 00000000..fe40d6f7 --- /dev/null +++ b/test/lib/completions/svn.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "svn " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/svnadmin.exp b/test/lib/completions/svnadmin.exp new file mode 100644 index 00000000..35e07021 --- /dev/null +++ b/test/lib/completions/svnadmin.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "svnadmin " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/svnlook.exp b/test/lib/completions/svnlook.exp new file mode 100644 index 00000000..33b67052 --- /dev/null +++ b/test/lib/completions/svnlook.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "svnlook " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sync_members.exp b/test/lib/completions/sync_members.exp new file mode 100644 index 00000000..4cb84ad8 --- /dev/null +++ b/test/lib/completions/sync_members.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sync_members --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sysctl.exp b/test/lib/completions/sysctl.exp new file mode 100644 index 00000000..cd7e7e3d --- /dev/null +++ b/test/lib/completions/sysctl.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +}; # setup() + + +proc teardown {} { + assert_env_unmodified +}; # teardown() + + +setup + + +assert_complete_any "sysctl fs" + + +sync_after_int + + +teardown diff --git a/test/lib/completions_to_review/sbcl-mt.exp b/test/lib/completions_to_review/sbcl-mt.exp deleted file mode 100644 index 51e15ba5..00000000 --- a/test/lib/completions_to_review/sbcl-mt.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sbcl-mt " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sbcl.exp b/test/lib/completions_to_review/sbcl.exp deleted file mode 100644 index 9f5561a6..00000000 --- a/test/lib/completions_to_review/sbcl.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sbcl " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/scp.exp b/test/lib/completions_to_review/scp.exp deleted file mode 100644 index d11af006..00000000 --- a/test/lib/completions_to_review/scp.exp +++ /dev/null @@ -1,119 +0,0 @@ -proc setup {} { - set test setup - set cmd "cd fixtures/scp" - send "$cmd\r" - expect -re "^$cmd\r\n/fixtures/scp/@" -}; # setup() - - -proc teardown {} { - set test teardown - set cmd "cd ../.." - send "$cmd\r" - expect -re "^$cmd\r\n/@" -}; # teardown() - - -setup - - -set test "Tab should complete remote pwd" - - # Retrieving `host_pwd' from ssh-host `bash_completion_lib' yields error? - # NOTE: The host should be set in e.g. .ssh/config or /etc/ssh_config -if { - [catch { - exec -- ssh -o "Batchmode yes" bash_completion_lib pwd 2>> /dev/null - } host_pwd] -} { - # Yes, retrieving pwd from ssh yields error; reset `host_pwd' - set host_pwd "" -} - - # Try completion -set cmd "scp bash_completion_lib:" -send "$cmd\t" -sync_after_tab -expect { - -re "^$cmd$host_pwd.*$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } -}; # expect - - -sleep .5 -sync_after_int - - -set test "Tab should complete scp known-hosts" - - # Build string list of completions, separated by regexp whitespace marker (\s+). - # Example string: comp1\s+comp2\s+comp3 - - # Get hostnames -set comps [exec bash -c "compgen -A hostname"] - # Hosts `gee' and `hus' are defined in ./fixtures/scp/config - # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts -lappend comps doo gee hus ike - # Append filenames `config' and `known_hosts' -lappend comps config known_hosts "spaced\\\\ \\\\ conf" -set comps [lsort -ascii $comps] -set comps [join $comps ":{0,1}\\s+"] - # Try completion -set cmd "scp -F config " -send "$cmd\t" -set expected "^${cmd}\r\n$comps:{0,1}\\s*/fixtures/scp/@$cmd$" -expect { - -re $expected { pass "$test" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -}; # expect - - -sync_after_int - - -set test "-F without space shouldn't error" - # Try completion -set cmd "scp -F" -send "$cmd\t " -set expected "^$cmd $" -expect { - -re "^${cmd}bash: option requires an argument -- F" { fail "$test" } - -re $expected { 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 completions, separated by regexp whitespace marker (\s+). - # Example string: comp1\s+comp2\s+comp3 - - # Get hostnames -set comps [exec bash -c "compgen -A hostname"] - # Hosts `gee' and `hus' are defined in ./fixtures/scp/config - # Hosts `doo' and `ike' are defined in ./fixtures/scp/known_hosts -lappend comps doo gee hus ike - # Append filenames `config' and `known_hosts' -lappend comps config known_hosts "spaced\\\\ \\\\ conf" -set comps [lsort -ascii $comps] -set comps [join $comps ":{0,1}\\s+"] - # Try completion -set cmd "scp -F 'spaced conf' " -send "$cmd\t" -set expected "^${cmd}\r\n$comps:{0,1}\\s*/fixtures/scp/@$cmd$" -expect { - -re $expected { pass "$test" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/screen.exp b/test/lib/completions_to_review/screen.exp deleted file mode 100644 index ee273268..00000000 --- a/test/lib/completions_to_review/screen.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "screen -s /" -send "$cmd\t" -expect { - -re "^${cmd}(grep: /etc/shells: No such file or directory|)\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sed.exp b/test/lib/completions_to_review/sed.exp deleted file mode 100644 index 91be8add..00000000 --- a/test/lib/completions_to_review/sed.exp +++ /dev/null @@ -1,27 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sed " -send "$cmd\t" -sync_after_tab -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/seq.exp b/test/lib/completions_to_review/seq.exp deleted file mode 100644 index c2bda8b5..00000000 --- a/test/lib/completions_to_review/seq.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "seq " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/service.exp b/test/lib/completions_to_review/service.exp deleted file mode 100644 index 3095725e..00000000 --- a/test/lib/completions_to_review/service.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should show completions" - # Try completion -set cmd "service " -send "$cmd\t" -expect { - -re "$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/set.exp b/test/lib/completions_to_review/set.exp deleted file mode 100644 index 39e70b02..00000000 --- a/test/lib/completions_to_review/set.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "set no" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sha1sum.exp b/test/lib/completions_to_review/sha1sum.exp deleted file mode 100644 index 6f8bb60b..00000000 --- a/test/lib/completions_to_review/sha1sum.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sha1sum " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/shar.exp b/test/lib/completions_to_review/shar.exp deleted file mode 100644 index 08ef458f..00000000 --- a/test/lib/completions_to_review/shar.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "shar " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sitecopy.exp b/test/lib/completions_to_review/sitecopy.exp deleted file mode 100644 index 8d0d2afc..00000000 --- a/test/lib/completions_to_review/sitecopy.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sitecopy " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/smartctl.exp b/test/lib/completions_to_review/smartctl.exp deleted file mode 100644 index e45b9f65..00000000 --- a/test/lib/completions_to_review/smartctl.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "smartctl --" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/snownews.exp b/test/lib/completions_to_review/snownews.exp deleted file mode 100644 index 3b7eccfc..00000000 --- a/test/lib/completions_to_review/snownews.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "snownews --" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sort.exp b/test/lib/completions_to_review/sort.exp deleted file mode 100644 index 6db7aa61..00000000 --- a/test/lib/completions_to_review/sort.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sort " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/split.exp b/test/lib/completions_to_review/split.exp deleted file mode 100644 index f9077943..00000000 --- a/test/lib/completions_to_review/split.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "split " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/spovray.exp b/test/lib/completions_to_review/spovray.exp deleted file mode 100644 index 85f59232..00000000 --- a/test/lib/completions_to_review/spovray.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "spovray " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/ssh.exp b/test/lib/completions_to_review/ssh.exp deleted file mode 100644 index 5b98d878..00000000 --- a/test/lib/completions_to_review/ssh.exp +++ /dev/null @@ -1,75 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete ssh known-hosts" - # 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/ssh/config - # Hosts `doo' and `ike' are defined in ./fixtures/ssh/known_hosts -lappend hosts doo gee hus ike -set hosts [lsort -ascii $hosts] -set hosts [join $hosts "\\s+"] - # Try completion -set cmd "ssh -F fixtures/ssh/config " -send "$cmd\t" -set expected "^$cmd\r\n$hosts\r\n/@$cmd$" -expect { - -re $expected { pass "$test" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -}; # expect - - -sync_after_int - - -set test "-F without space shouldn't error" - # Try completion -set cmd "ssh -F" -send "$cmd\t " -set expected "^$cmd $" -expect { - -re "^${cmd}bash: option requires an argument -- F" { fail "$test" } - -re $expected { 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/ssh/config - # Hosts `doo' and `ike' are defined in ./fixtures/ssh/known_hosts - # Host `two' is defined in ./fixtures/ssh/known_hosts2 -lappend hosts doo gee hus ike two -set hosts [lsort -ascii $hosts] -set hosts [join $hosts "\\s+"] - # Try completion -set cmd "ssh -F 'fixtures/ssh/spaced conf' " -send "$cmd\t" -set expected "^$cmd\r\n$hosts\r\n/@$cmd$" -expect { - -re $expected { pass "$test" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sshmitm.exp b/test/lib/completions_to_review/sshmitm.exp deleted file mode 100644 index 6fbfa487..00000000 --- a/test/lib/completions_to_review/sshmitm.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sshmitm -" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sshow.exp b/test/lib/completions_to_review/sshow.exp deleted file mode 100644 index 683a9242..00000000 --- a/test/lib/completions_to_review/sshow.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sshow -" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/strip.exp b/test/lib/completions_to_review/strip.exp deleted file mode 100644 index ad73514f..00000000 --- a/test/lib/completions_to_review/strip.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "strip " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sudo.exp b/test/lib/completions_to_review/sudo.exp deleted file mode 100644 index e0799fb3..00000000 --- a/test/lib/completions_to_review/sudo.exp +++ /dev/null @@ -1,25 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sudo cd fixture1/fo" -send "$cmd\t" -expect { - -re "^sudo cd fixture1/foo.d/$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/svk.exp b/test/lib/completions_to_review/svk.exp deleted file mode 100644 index c4bd3e71..00000000 --- a/test/lib/completions_to_review/svk.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "svk " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/svn.exp b/test/lib/completions_to_review/svn.exp deleted file mode 100644 index bef9c050..00000000 --- a/test/lib/completions_to_review/svn.exp +++ /dev/null @@ -1,41 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "svn " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -set test "Completing --editor-cmd should invoke _command" - # Try completion -set cmd "svn commit --editor-cmd vim" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/svnadmin.exp b/test/lib/completions_to_review/svnadmin.exp deleted file mode 100644 index fabf5c91..00000000 --- a/test/lib/completions_to_review/svnadmin.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "svnadmin " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/svnlook.exp b/test/lib/completions_to_review/svnlook.exp deleted file mode 100644 index ab4adf39..00000000 --- a/test/lib/completions_to_review/svnlook.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "svnlook " -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sync_members.exp b/test/lib/completions_to_review/sync_members.exp deleted file mode 100644 index 370709a4..00000000 --- a/test/lib/completions_to_review/sync_members.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sync_members --" -send "$cmd\t" -expect { - -re "^$cmd\r\n.*$cmd$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/completions_to_review/sysctl.exp b/test/lib/completions_to_review/sysctl.exp deleted file mode 100644 index 6793cf2c..00000000 --- a/test/lib/completions_to_review/sysctl.exp +++ /dev/null @@ -1,29 +0,0 @@ -proc setup {} { -}; # setup() - - -proc teardown {} { -}; # teardown() - - -setup - - -set test "Tab should complete" - # Try completion -set cmd "sysctl " -send "$cmd\t" - # NOTE: Wait in case `sysctl' returns nothing, so that "^$cdm.*$" doesn't match - # too early -- before comp_install has finished -sleep 1 -expect { - -re "^$cmd\.*$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - -re eof { unresolved "eof" } -}; # expect - - -sync_after_int - - -teardown diff --git a/test/lib/library.exp b/test/lib/library.exp index 968c4323..3299ccba 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -65,8 +65,12 @@ proc assert_complete {expected cmd {test ""} {prompt /@} {size 20}} { send "$cmd\t" if {[llength $expected] == 1} { expect -ex "$cmd" - # Assume second word is word to complete on. - set cur [lindex [split $cmd] 1] + set cmds [split $cmd] + set cur ""; # Default to empty word to complete on + if {[llength $cmds] > 1} { + # Assume last word of `$cmd' is word to complete on. + set cur [lindex $cmds [expr [llength $cmds] - 1]] + }; # if # Remove second word from beginning of single item $expected if {[string first $cur $expected] == 0} { set expected [string range $expected [string length $cur] end] @@ -181,7 +185,7 @@ proc assert_complete_partial {expected cmd {partial ""} {test ""} {prompt /@} {s # # Replace `COMP_PATH=.*' with `COMP_PATH=PATH' # assert_env_unmodified {s/COMP_PATH=.*/COMP_PATH=PATH/} # -# # Remove lines containing with `OLDPWD=' +# # Remove lines containing `OLDPWD=' # assert_env_unmodified {/OLDPWD=/d} # # @param string $file Filename to generate environment save file from. See @@ -277,7 +281,7 @@ proc get_hosts {} { type avahi-browse >&/dev/null && [ -n "$(pidof avahi-daemon)" ] avahi-browse -cpr _workstation._tcp | grep ^= | cut -d\; -f7 | sort -u }] - if {[llength $avahi_hosts] > 1} { + if {[llength $avahi_hosts] > 0} { lappend hosts $avahi_hosts }; # if return $hosts @@ -342,7 +346,6 @@ proc match_items {items test {size 20}} { # Get real command. # - arg: $1 Command -# - stdout: Filename of command in PATH with possible symbolic links resolved. # - return: Command found, empty string if not found proc realcommand {cmd} { set result "" diff --git a/test/lib/library.sh b/test/lib/library.sh index e9b4d43a..df683c6d 100644 --- a/test/lib/library.sh +++ b/test/lib/library.sh @@ -10,7 +10,7 @@ # @param $1 Additional sed script diff_env() { diff "$1" "$2" | sed -e " - /^[0-9]\+[acd]/d # Remove diff line indicators + /^[0-9,]\+[acd]/d # Remove diff line indicators /---/d # Remove diff block separators /[<>] _=/d # Remove underscore variable /[<>] PPID=/d # Remove PPID bash variable |