diff options
Diffstat (limited to 'test/lib/completions')
-rw-r--r-- | test/lib/completions/alias.exp | 32 | ||||
-rw-r--r-- | test/lib/completions/cd.exp | 31 | ||||
-rw-r--r-- | test/lib/completions/chown.exp | 43 | ||||
-rw-r--r-- | test/lib/completions/finger.exp | 41 | ||||
-rw-r--r-- | test/lib/completions/scp.exp | 117 | ||||
-rw-r--r-- | test/lib/completions/sftp.exp | 60 | ||||
-rw-r--r-- | test/lib/completions/slapt-get.exp | 32 | ||||
-rw-r--r-- | test/lib/completions/slapt-src.exp | 29 | ||||
-rw-r--r-- | test/lib/completions/ssh.exp | 61 | ||||
-rw-r--r-- | test/lib/completions/sudo.exp | 42 | ||||
-rw-r--r-- | test/lib/completions/umount.exp | 95 | ||||
-rw-r--r-- | test/lib/completions/upgradepkg.exp | 26 | ||||
-rw-r--r-- | test/lib/completions/xhost.exp | 95 |
13 files changed, 0 insertions, 704 deletions
diff --git a/test/lib/completions/alias.exp b/test/lib/completions/alias.exp deleted file mode 100644 index c41417f1..00000000 --- a/test/lib/completions/alias.exp +++ /dev/null @@ -1,32 +0,0 @@ -proc setup {} { - assert_bash_exec "unalias -a"; # Remove all aliases - assert_bash_exec "alias foo=bar" - assert_bash_exec "alias bar='foo foo'" - save_env -} - - -proc teardown {} { - assert_bash_exec "unalias -a"; # Remove all aliases - assert_env_unmodified -} - - -setup - - -set test "Tab should complete alias at cursor position" - # Try completion -set cmd "alias foo" -append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode -send "$cmd\t" -expect { - -re "^alias foo\b\b\b\r\nbar +foo *\r\n/@alias foo\b\b\b$" { pass "$test" } - -re "^alias foo\b\b\bfoo=foo\b\b\b$" { fail "$test: Wrong cursor position" } - -re /@ { unresolved "$test" } - default { unresolved "$test" } -} -sync_after_int - - -teardown diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp deleted file mode 100644 index ded094c3..00000000 --- a/test/lib/completions/cd.exp +++ /dev/null @@ -1,31 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified {/OLDPWD=/d} -} - - -setup - - -set test "Tab should complete cd at cursor position" - # Try completion -set cmd "cd $::srcdir/fixtures/shared/default/foo" -append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode -#append cmd \033\0133D; # Escape-[-D = Cursor left -send "$cmd\t" -expect { - -re "cd $::srcdir/fixtures/shared/default/foo\b\b\b\r\n(\.svn/ +|)bar bar.d/ +foo.d/ *(\.svn/ *|)\r\n/@cd $::srcdir/fixtures/shared/default/foo\b\b\b$" { pass "$test" } - -re "^cd $::srcdir/fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -} - - -sync_after_int - - -teardown diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp deleted file mode 100644 index 792d52a9..00000000 --- a/test/lib/completions/chown.exp +++ /dev/null @@ -1,43 +0,0 @@ -proc setup {} { - # fake root command to get all users/groups completed at least for now - assert_bash_exec {root_command=sudo} - save_env -} - -proc teardown {} { - assert_env_unmodified -} - - -setup - - -# Find user/group suitable for testing. -set failed_find_unique_completion 0 -foreach ug {user group} { - # compgen -A is used because it's a bash builtin and available everywhere. - # The || true part prevents exec from throwing an exception if nothing is - # found (very very unlikely). - set list [split [exec bash -c "compgen -A $ug || true"] "\n"] - if {![find_unique_completion_pair $list part$ug full$ug]} { - untested "Not running complex chown tests; no suitable test $ug found." - set failed_find_unique_completion 1 - } -} - -# These tests require an unique completion. -if {!$failed_find_unique_completion} { - - foreach prefix { - "funky\\ user:" "funky.user:" "funky\\.user:" "fu\\ nky.user:" - "f\\ o\\ o\\.\\bar:" "foo\\_b\\ a\\.r\\ :" - } { - set test "Check preserve special chars in $prefix$partgroup<TAB>" - #assert_complete_into "chown $prefix$partgroup" "chown $prefix$fullgroup " $test - assert_complete $prefix$fullgroup "chown $prefix$partgroup" $test - sync_after_int - } -} - - -teardown diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp deleted file mode 100644 index c055f354..00000000 --- a/test/lib/completions/finger.exp +++ /dev/null @@ -1,41 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified -} - - -setup - - -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 unique hostnames starting with $char - if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} { - # Prefix hosts with username 'test@' - lappend hosts "test@$h" - } - } -} -assert_complete $hosts "finger test@$char" $test -expect-cmd-minus "test@$char" - - -sync_after_int - - -teardown diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp deleted file mode 100644 index 1497a7fb..00000000 --- a/test/lib/completions/scp.exp +++ /dev/null @@ -1,117 +0,0 @@ -proc setup {} { - save_env - # 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} -} - - -proc teardown {} { - assert_bash_exec {cd $TESTDIR} - assert_env_unmodified { - /BASH_LINENO=/d - /BASH_SOURCE=/d - /OLDPWD=/d - } -} - - -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 -} - - - # Try completion -set cmd "scp $host:" -send "$cmd\t" -sync_after_tab -expect { - -re "^$cmd$host_pwd.*$" { pass "$test" } - -re /@ { unresolved "$test at prompt" } -} - - -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 `hut' are defined in ./fixtures/scp/config - # Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts -set expected {} -foreach host [get_hosts] { - lappend expected "$host:" -} -lappend expected blah: doo: gee: hut: ike: - # Append local filenames -lappend expected config known_hosts "spaced\\ \\ conf" -assert_complete $expected "scp -F config " $test - - -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" } -} - - -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:" -} - # Hosts `gee', `hus' and `jar' are defined in "./fixtures/scp/spaced conf" - # Hosts `blah', `doo' and `ike' are defined in ./fixtures/scp/known_hosts -lappend expected blah: doo: gee: hus: ike: jar: - # Append local filenames -lappend expected config known_hosts "spaced\\ \\ conf" -set cmd "scp -F 'spaced conf' " -send "$cmd\t" -expect -ex "$cmd\r\n" -if {[match_items [lsort -unique $expected] -bash-sort]} { - expect { - -re /@ { pass "$test" } - -re eof { unresolved "eof" } - default { fail "$test" } - } -} -sync_after_int -assert_bash_exec {cd "$TESTDIR"} - - -sync_after_int - - -teardown diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp deleted file mode 100644 index c5c0919f..00000000 --- a/test/lib/completions/sftp.exp +++ /dev/null @@ -1,60 +0,0 @@ -proc setup {} { - save_env - # 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/sftp} -} - - -proc teardown {} { - assert_bash_exec {cd $TESTDIR} - assert_env_unmodified { - /BASH_LINENO=/d - /BASH_SOURCE=/d - /OLDPWD=/d - } -} - - -setup - - - # Build string list of expected completions -set expected [get_hosts] - # Hosts `gee' and `hut' are defined in ./fixtures/sftp/config - # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts -lappend expected 10.10.10.10 doo gee hut ike -assert_complete $expected "sftp -F config " - - -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" } -} - - -sync_after_int - - - # Build string list of expected completions - # Get hostnames and give them a colon (:) suffix -set expected [get_hosts] - # Hosts `gee' and `jar' are defined in "./fixtures/sftp/spaced conf" - # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts -lappend expected 10.10.10.10 doo gee ike jar -assert_complete $expected "sftp -F spaced\\ \\ conf " - - -sync_after_int - - -teardown diff --git a/test/lib/completions/slapt-get.exp b/test/lib/completions/slapt-get.exp deleted file mode 100644 index 4522610d..00000000 --- a/test/lib/completions/slapt-get.exp +++ /dev/null @@ -1,32 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified -} - - -setup - - -set test "--install should complete available packages" -set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-getrc -set workdir [file normalize $::srcdir/fixtures/slackware/var/slapt-get/] -set pkg_data "$workdir/package_data" -# write simple config -set f [open $config w] -puts $f "WORKINGDIR=$workdir" -puts $f "SOURCE=file:///home/" -close $f -set packages [split [exec bash -c "sed -n \ - '/^PACKAGE NAME:/{s/^PACKAGE NAME: \\{1,\\}\\(.*\\).t\[gbxl\]z/\\1/;p}' \ - $pkg_data"] "\n"] -assert_complete $packages "slapt-get -c $config --install " $test - - -sync_after_int - - -teardown diff --git a/test/lib/completions/slapt-src.exp b/test/lib/completions/slapt-src.exp deleted file mode 100644 index b66385ef..00000000 --- a/test/lib/completions/slapt-src.exp +++ /dev/null @@ -1,29 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified -} - - -setup - - -set test "--install should complete available packages" -set config $::srcdir/fixtures/slackware/etc/slapt-get/slapt-srcrc -set workdir [file normalize $::srcdir/fixtures/slackware/usr/src/slapt-src/] -set slb_data "$workdir/slackbuilds_data" -set f [open $config w]; puts $f "BUILDDIR=$workdir"; close $f -set slackbuilds [split [exec bash -c "sed -n \ - -e '/^SLACKBUILD NAME: /{s/^SLACKBUILD NAME: \\{1,\\}//;p}' \ - -e '/^SLACKBUILD VERSION: /{s/^SLACKBUILD VERSION: \\{1,\\}//;p}' \ - $slb_data | sed -e 'N;s/\\n/:/'"] "\n"] -assert_complete $slackbuilds "slapt-src --config $config --install " $test - - -sync_after_int - - -teardown diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp deleted file mode 100644 index 1702371c..00000000 --- a/test/lib/completions/ssh.exp +++ /dev/null @@ -1,61 +0,0 @@ -proc setup {} { - save_env - # 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/ssh} -} - - -proc teardown {} { - assert_bash_exec {cd $TESTDIR} - assert_env_unmodified { - /BASH_LINENO=/d - /BASH_SOURCE=/d - /OLDPWD=/d - } -} - - -setup - - -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 "^$cmd\r\n.*\r\n/@" { pass "$test" } - -re /@ { unresolved "$test at prompt" } - default { unresolved "$test" } -} - - -sync_after_int - - -set test "First argument 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 unique hostnames starting with $char - if {$first == $char && [lsearch -exact $hosts "$h"] == -1} { - lappend hosts "$h" - } - } -} -assert_complete $hosts "ssh $char" $test -ltrim-colon-completions -expect-cmd-minus "$char" - - -sync_after_int - - -teardown diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp deleted file mode 100644 index 73e485d6..00000000 --- a/test/lib/completions/sudo.exp +++ /dev/null @@ -1,42 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified {/OLDPWD/d} -} - - -setup - - -# Find user/group suitable for testing. -set failed_find_unique_completion 0 -foreach ug {user group} { - # compgen -A is used because it's a bash builtin and available everywhere. - # The || true part prevents exec from throwing an exception if nothing is - # found (very very unlikely). - set list [split [exec bash -c "compgen -A $ug || true"] "\n"] - if {![find_unique_completion_pair $list part$ug full$ug]} { - untested "Not running complex chown tests; no suitable test $ug found." - set failed_find_unique_completion 1 - } -} - -# These tests require an unique completion. -if {!$failed_find_unique_completion} { - - foreach prefix { - "funky\\ user:" "funky.user:" "funky\\.user:" "fu\\ nky.user:" - "f\\ o\\ o\\.\\bar:" "foo\\_b\\ a\\.r\\ :" - } { - set test "Check preserve special chars in $prefix$partgroup<TAB>" - #assert_complete_into "chown $prefix$partgroup" "chown $prefix$fullgroup " $test - assert_complete $prefix$fullgroup "sudo chown $prefix$partgroup" $test - sync_after_int - } -} - - -teardown diff --git a/test/lib/completions/umount.exp b/test/lib/completions/umount.exp deleted file mode 100644 index 03144355..00000000 --- a/test/lib/completions/umount.exp +++ /dev/null @@ -1,95 +0,0 @@ -# umount completion from fstab can't be tested directly because it -# (correctly) uses absolute paths. So we create a custom completion which -# reads from a file in our text fixture instead. -proc setup_dummy_mnt {} { - assert_bash_exec {unset COMPREPLY cur} - assert_bash_exec {unset -f _mnt} - - assert_bash_exec { \ - _mnt() { \ - local cur=$(_get_cword); \ - _linux_fstab $(_get_pword) < "$SRCDIRABS/fixtures/mount/test-fstab"; \ - }; \ - complete -F _mnt mnt \ - } -} - - -proc teardown_dummy_mnt {} { - assert_bash_exec {unset COMPREPLY cur} - assert_bash_exec {unset -f _mnt} - assert_bash_exec {complete -r mnt} -} - - -proc setup {} { - save_env - setup_dummy_mnt -} - - -proc teardown {} { - teardown_dummy_mnt - assert_env_unmodified {/OLDPWD/d} -} - - -setup - - -set test "Testing internal __linux_fstab_unescape function for umount" -# One round of slashes is for bash. -assert_bash_exec {var=one\'two\\040three\\} -assert_bash_exec {__linux_fstab_unescape var} -set cmd {echo $var} -send "$cmd\r" -expect { - -ex "$cmd\r\none'two three\\" { pass $test } -# default { fail $test } -} -sync_after_int -assert_bash_exec {unset var} - - -sync_after_int - - -# Begin testing through mnt (see setup_dummy_mnt). -assert_complete {/mnt/nice-test-path} {mnt /mnt/nice-test-p} -sync_after_int - -assert_complete {/mnt/nice\ test-path} {mnt /mnt/nice\ test-p} -sync_after_int - -assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$test-p} -sync_after_int - -assert_complete {/mnt/nice\ test\\path} {mnt /mnt/nice\ test\\p} -sync_after_int - -assert_complete {{/mnt/nice\ test\\path} {/mnt/nice\ test-path}} \ - {mnt /mnt/nice\ } "" -expect-cmd-minus {/mnt/nice\ } -sync_after_int - -assert_complete {/mnt/nice\$test-path} {mnt /mnt/nice\$} -sync_after_int - -assert_complete {/mnt/nice\'test-path} {mnt /mnt/nice\'} -sync_after_int - -assert_complete {/mnt/other\'test\ path} {mnt /mnt/other} -sync_after_int - -assert_complete {Ubuntu\ Karmic} {mnt -L Ubu} -sync_after_int - -assert_complete {Debian-it\'s\ awesome} {mnt -L Deb} -sync_after_int - -# This does not work. Proper support for this requires smarter parsing of -# $COMP_LINE and it's not worth doing just for umount. -#assert_complete {$'/mnt/nice\ntest-path'} {mnt $'/mnt/nice\n} -#sync_after_int - - -teardown diff --git a/test/lib/completions/upgradepkg.exp b/test/lib/completions/upgradepkg.exp deleted file mode 100644 index ffb4ba28..00000000 --- a/test/lib/completions/upgradepkg.exp +++ /dev/null @@ -1,26 +0,0 @@ -proc setup {} { - save_env -} - - -proc teardown {} { - assert_env_unmodified {/OLDPWD=/d} -} - - -setup - - -set test "should complete *.t\[gbxl\]z files and dirs after % sign" -set oldpkg "xx-2.0-i486-2" -set dir $::srcdir/fixtures/slackware/home -set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \ - \\( -type d -printf '$oldpkg%%%P/\\n' \\) -o \ - \\( -type f -name '*.t\[bglx\]z' -printf '$oldpkg%%%P\\n' \\)"] "\n"] -assert_complete_dir $files "upgradepkg $oldpkg%" $dir $test - - -sync_after_int - - -teardown diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp deleted file mode 100644 index 02aa4cb2..00000000 --- a/test/lib/completions/xhost.exp +++ /dev/null @@ -1,95 +0,0 @@ -proc setup {} { - assert_bash_exec {HOME=$TESTDIR} - save_env -} - - -proc teardown {} { - assert_env_unmodified -} - - -setup - - -set test "Tab should complete hostnames" -assert_complete [get_hosts] "xhost " $test - - -sync_after_int - - -set test "Tab should complete partial hostname" -# Build string list of hostnames, starting with the character of the first hostname -set hosts {} -set char "" -foreach h [get_hosts] { - if {$char == ""} {set char [string range $h 0 0]} - # Only append hostname if starting with $char - if {[string range $h 0 0] == "$char"} { - lappend hosts $h - } -} -assert_complete $hosts "xhost $char" $test -expect-cmd-minus "$char" - - -sync_after_int - - -set test "Tab should complete hostnames prefixed with +" -# Build string list of hostnames, prefixed with plus (+) -set hosts {} -foreach h [get_hosts] { - lappend hosts "+$h" -} -assert_complete $hosts "xhost \+" $test - - -sync_after_int - - -set test "Tab should complete partial hostname prefixed with +" - # Build string list of hostnames, starting with character of first host. -set hosts {} -foreach h [get_hosts] { - if {$char == ""} {set char [string range $h 0 0]} - # Only append hostname if starting with $char - if {[string range $h 0 0] == "$char"} { - lappend hosts "+$h" - } -} -assert_complete $hosts "xhost +$char" $test -expect-cmd-minus "\+$char" - - -sync_after_int - - -set test "Tab should complete hostnames prefixed with -" - # Build string list of hostnames, prefix with minus (-) -set hosts {} -foreach h [get_hosts] { - lappend hosts "-$h" -} -assert_complete $hosts "xhost -" $test - - -sync_after_int - - -set test "Tab should complete partial hostname prefixed with -" - # Build list of hostnames, starting with character of first host -set hosts {} -foreach h [get_hosts] { - if {$char == ""} {set char [string range $h 0 0]} - # Only append hostname if starting with $char - if {[string range $h 0 0] == "$char"} { - lappend hosts "-$h" - } -} -assert_complete $hosts "xhost -$char" $test -expect-cmd-minus "-$char" - - -sync_after_int - - -teardown |