diff options
| author | David Paleino <dapal@debian.org> | 2011-11-03 12:32:52 +0100 |
|---|---|---|
| committer | David Paleino <dapal@debian.org> | 2011-11-03 12:32:52 +0100 |
| commit | 2c8171c38d87ddef31c92a76547d3fdf773a1337 (patch) | |
| tree | 5e720d5a06ead72ed55454bf6647a712a761ed91 /test/lib | |
| parent | 9920a8faedf704420571d8072ccab27e9dac40ba (diff) | |
| download | bash-completion-2c8171c38d87ddef31c92a76547d3fdf773a1337.tar.gz | |
Imported Upstream version 1.90upstream/1.90
Diffstat (limited to 'test/lib')
172 files changed, 2701 insertions, 128 deletions
diff --git a/test/lib/completions/a2x.exp b/test/lib/completions/a2x.exp new file mode 100644 index 00000000..e1ca8844 --- /dev/null +++ b/test/lib/completions/a2x.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "a2x " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ant.exp b/test/lib/completions/ant.exp index de57f24a..acff23ec 100644 --- a/test/lib/completions/ant.exp +++ b/test/lib/completions/ant.exp @@ -4,7 +4,9 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified { + /OLDPWD=/d + } } @@ -12,8 +14,10 @@ setup assert_complete_any "ant -" +sync_after_int +assert_complete_dir "bashcomp clean init realclean" "ant " $::srcdir/fixtures/ant sync_after_int diff --git a/test/lib/completions/arping.exp b/test/lib/completions/arping.exp new file mode 100644 index 00000000..531bb07f --- /dev/null +++ b/test/lib/completions/arping.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "arping " +sync_after_int + +assert_complete_any "arping -" +sync_after_int + + +teardown diff --git a/test/lib/completions/asciidoc.exp b/test/lib/completions/asciidoc.exp new file mode 100644 index 00000000..86e7609a --- /dev/null +++ b/test/lib/completions/asciidoc.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "asciidoc " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/avctrl.exp b/test/lib/completions/avctrl.exp new file mode 100644 index 00000000..6ca9de70 --- /dev/null +++ b/test/lib/completions/avctrl.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "avctrl " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/base64.exp b/test/lib/completions/base64.exp new file mode 100644 index 00000000..1f3f35cf --- /dev/null +++ b/test/lib/completions/base64.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "base64 " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/c++.exp b/test/lib/completions/c++.exp index 4dffb042..c899de27 100644 --- a/test/lib/completions/c++.exp +++ b/test/lib/completions/c++.exp @@ -11,7 +11,6 @@ proc teardown {} { setup -set test "Tab should complete" assert_complete_any "c++ " diff --git a/test/lib/completions/cal.exp b/test/lib/completions/cal.exp new file mode 100644 index 00000000..bf7185e2 --- /dev/null +++ b/test/lib/completions/cal.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cal " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/cfagent.exp b/test/lib/completions/cfagent.exp new file mode 100644 index 00000000..aa5c88cb --- /dev/null +++ b/test/lib/completions/cfagent.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cfagent -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/chage.exp b/test/lib/completions/chage.exp new file mode 100644 index 00000000..e5399054 --- /dev/null +++ b/test/lib/completions/chage.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chage " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp index bc1a8c7f..6bfd9d05 100644 --- a/test/lib/completions/chown.exp +++ b/test/lib/completions/chown.exp @@ -69,5 +69,11 @@ if {!$failed_find_unique_completion} { sync_after_int } +assert_complete {bar "bar bar.d/" foo foo.d/} "chown foo: $::srcdir/fixtures/shared/default/" +sync_after_int + +assert_complete {bar "bar bar.d/" foo foo.d/} "chown :foo $::srcdir/fixtures/shared/default/" +sync_after_int + teardown diff --git a/test/lib/completions/chpasswd.exp b/test/lib/completions/chpasswd.exp new file mode 100644 index 00000000..84c3345f --- /dev/null +++ b/test/lib/completions/chpasswd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chpasswd -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/chrpath.exp b/test/lib/completions/chrpath.exp new file mode 100644 index 00000000..311628eb --- /dev/null +++ b/test/lib/completions/chrpath.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "chrpath " +sync_after_int + +assert_complete_any "chrpath -" +sync_after_int + + +teardown diff --git a/test/lib/completions/chsh.exp b/test/lib/completions/chsh.exp index a26ac93f..6736c18c 100644 --- a/test/lib/completions/chsh.exp +++ b/test/lib/completions/chsh.exp @@ -17,7 +17,7 @@ assert_complete_any "chsh -s " sync_after_int -assert_complete [exec bash -c "compgen -A user"] "chsh " +assert_complete_any "chsh " sync_after_int diff --git a/test/lib/completions/ciptool.exp b/test/lib/completions/ciptool.exp new file mode 100644 index 00000000..cefe8f92 --- /dev/null +++ b/test/lib/completions/ciptool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ciptool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/compare.exp b/test/lib/completions/compare.exp new file mode 100644 index 00000000..006d70a1 --- /dev/null +++ b/test/lib/completions/compare.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "compare " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/conjure.exp b/test/lib/completions/conjure.exp new file mode 100644 index 00000000..4f628af3 --- /dev/null +++ b/test/lib/completions/conjure.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "conjure " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/convert.exp b/test/lib/completions/convert.exp index 07032040..b3a2e565 100644 --- a/test/lib/completions/convert.exp +++ b/test/lib/completions/convert.exp @@ -12,8 +12,10 @@ setup assert_complete_any "convert " +sync_after_int +assert_complete_any "convert -format " sync_after_int diff --git a/test/lib/completions/cppcheck.exp b/test/lib/completions/cppcheck.exp new file mode 100644 index 00000000..4acd709a --- /dev/null +++ b/test/lib/completions/cppcheck.exp @@ -0,0 +1,30 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "cppcheck " +sync_after_int + + +assert_complete_any "cppcheck -" +sync_after_int + + +assert_complete_any "cppcheck -DFOO=BAR " +sync_after_int + + +assert_no_complete "cppcheck -D " +sync_after_int + + +teardown diff --git a/test/lib/completions/curl.exp b/test/lib/completions/curl.exp new file mode 100644 index 00000000..53512bc4 --- /dev/null +++ b/test/lib/completions/curl.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "curl -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/cvs.exp b/test/lib/completions/cvs.exp index 3b2643d3..9248edc8 100644 --- a/test/lib/completions/cvs.exp +++ b/test/lib/completions/cvs.exp @@ -8,6 +8,7 @@ proc teardown {} { assert_bash_exec {HOME=$OLDHOME} assert_env_unmodified { /OLDHOME=/d + /OLDPWD=/d } } @@ -33,4 +34,8 @@ expect { sync_after_int +assert_complete_dir "foo/bar" "cvs diff foo/" $::srcdir/fixtures/cvs +sync_after_int + + teardown diff --git a/test/lib/completions/dfutool.exp b/test/lib/completions/dfutool.exp new file mode 100644 index 00000000..10e48544 --- /dev/null +++ b/test/lib/completions/dfutool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "dfutool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/display.exp b/test/lib/completions/display.exp index e9fe766a..70cea182 100644 --- a/test/lib/completions/display.exp +++ b/test/lib/completions/display.exp @@ -17,22 +17,7 @@ assert_complete_any "display " sync_after_int -set test "- should complete options" -set options { - -alpha -antialias -authenticate -auto-orient -backdrop -background -border - -bordercolor -borderwidth -channel -clip -clip-path -coalesce -colormap - -colors -colorspace -comment -compress -contrast -crop -debug -decipher - -define -delay -density -depth -despeckle -display -dispose -dither -edge - -endian -enhance -extract -filter -flatten -flip -flop -font -foreground - -format -frame -gamma -geometry -help -iconGeometry -iconic -identify - -immutable -interlace -interpolate -label -limit -list -log -loop -map - -mattecolor -monitor -monochrome -name -negate -page -profile -quality - -quantize -quiet -raise -regard-warnings -remote -repage -resample -resize - -respect-parenthesis -roll -rotate -sample -sampling-factor -scenes -seed - -segment -set -shared-memory -sharpen -size -strip -texture -title - -transparent-color -treedepth -trim -update -usePixmap -verbose -version - -virtual-pixel -visual -window -window-group -write } -assert_complete $options "display -" $test +assert_complete_any "display -" sync_after_int diff --git a/test/lib/completions/dmesg.exp b/test/lib/completions/dmesg.exp new file mode 100644 index 00000000..79f2e04a --- /dev/null +++ b/test/lib/completions/dmesg.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "dmesg -" +sync_after_int + + +teardown diff --git a/test/lib/completions/dot.exp b/test/lib/completions/dot.exp new file mode 100644 index 00000000..2a85a56b --- /dev/null +++ b/test/lib/completions/dot.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "dot " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/explodepkg.exp b/test/lib/completions/explodepkg.exp new file mode 100644 index 00000000..e5ee35e4 --- /dev/null +++ b/test/lib/completions/explodepkg.exp @@ -0,0 +1,25 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +set test "should complete *.t\[gbxl\]z files and dirs" +set dir $::srcdir/fixtures/slackware/home +set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \ + \\( -type d -printf '%P/\\n' \\) -o \ + \\( -type f -name '*.t\[bglx\]z' -printf '%P\\n' \\)"] "\n"] +assert_complete_dir $files "explodepkg " $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/faillog.exp b/test/lib/completions/faillog.exp new file mode 100644 index 00000000..9ccd1ad2 --- /dev/null +++ b/test/lib/completions/faillog.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "faillog -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/fbgs.exp b/test/lib/completions/fbgs.exp new file mode 100644 index 00000000..45fa22df --- /dev/null +++ b/test/lib/completions/fbgs.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "fbgs " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/fbi.exp b/test/lib/completions/fbi.exp new file mode 100644 index 00000000..9c583062 --- /dev/null +++ b/test/lib/completions/fbi.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "fbi " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/feh.exp b/test/lib/completions/feh.exp new file mode 100644 index 00000000..129e1f4d --- /dev/null +++ b/test/lib/completions/feh.exp @@ -0,0 +1,55 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "feh " + + +sync_after_int + + +set test "--lis<TAB> should complete \"--list\"" +assert_complete "--list" "feh --lis" $test + + +sync_after_int + + +set test "-S pix<TAB> should complete \"pixels\"" +assert_complete "pixels" "feh -S pix" $test + + +sync_after_int + + +set test "--zoom ma<TAB> should complete \"max\"" +assert_complete "max" "feh --zoom ma" $test + + +sync_after_int + + +set test "-g 640<TAB> should complete digits plus \"x\"" +assert_complete "0 1 2 3 4 5 6 7 8 9 x" "feh -g 640" $test + + +sync_after_int + + +set test "-g 640x48<TAB> should complete digits" +assert_complete "0 1 2 3 4 5 6 7 8 9" "feh -g 640x48" $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/file.exp b/test/lib/completions/file.exp new file mode 100644 index 00000000..346960b6 --- /dev/null +++ b/test/lib/completions/file.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "file " +sync_after_int + +assert_complete_any "file -" +sync_after_int + + +teardown diff --git a/test/lib/completions/find.exp b/test/lib/completions/find.exp index 9acda648..96d55334 100644 --- a/test/lib/completions/find.exp +++ b/test/lib/completions/find.exp @@ -43,7 +43,7 @@ sync_after_int set test "-wholename should complete files/dirs" set dir $::srcdir/fixtures/shared/default set files [split [exec bash -c "cd $dir && ls -p"] "\n"] -assert_complete_dir $files "find -wholename " $dir +assert_complete_dir $files "find -wholename " $dir $test sync_after_int diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp index 70e3ed2c..f11d11fe 100644 --- a/test/lib/completions/finger.exp +++ b/test/lib/completions/finger.exp @@ -24,7 +24,7 @@ sync_after_int set test "Tab should complete partial username" -assert_complete_partial [exec bash -c "compgen -A user"] "finger" -nospace +assert_complete_partial [exec bash -c "compgen -A user"] "finger" "" $test -nospace sync_after_int @@ -48,7 +48,7 @@ foreach h [get_known_hosts] { } } } -assert_complete $hosts "finger test@$char" $test +assert_complete $hosts "finger test@$char" $test -expect-cmd-minus "test@$char" sync_after_int diff --git a/test/lib/completions/fusermount.exp b/test/lib/completions/fusermount.exp new file mode 100644 index 00000000..f6ac4f5d --- /dev/null +++ b/test/lib/completions/fusermount.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "fusermount " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/gendiff.exp b/test/lib/completions/gendiff.exp new file mode 100644 index 00000000..cc1ebb68 --- /dev/null +++ b/test/lib/completions/gendiff.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "gendiff " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/gnome-mplayer.exp b/test/lib/completions/gnome-mplayer.exp new file mode 100644 index 00000000..fd635bff --- /dev/null +++ b/test/lib/completions/gnome-mplayer.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "gnome-mplayer " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/gpasswd.exp b/test/lib/completions/gpasswd.exp new file mode 100644 index 00000000..68ac2cc3 --- /dev/null +++ b/test/lib/completions/gpasswd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "gpasswd " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/grpck.exp b/test/lib/completions/grpck.exp new file mode 100644 index 00000000..385ebe2b --- /dev/null +++ b/test/lib/completions/grpck.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "grpck " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/hciattach.exp b/test/lib/completions/hciattach.exp new file mode 100644 index 00000000..35642f28 --- /dev/null +++ b/test/lib/completions/hciattach.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hciattach " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/hciconfig.exp b/test/lib/completions/hciconfig.exp new file mode 100644 index 00000000..56444f4f --- /dev/null +++ b/test/lib/completions/hciconfig.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hciconfig " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/hddtemp.exp b/test/lib/completions/hddtemp.exp new file mode 100644 index 00000000..a6721dbf --- /dev/null +++ b/test/lib/completions/hddtemp.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "hddtemp -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/host.exp b/test/lib/completions/host.exp new file mode 100644 index 00000000..73081821 --- /dev/null +++ b/test/lib/completions/host.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "host -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/htpasswd.exp b/test/lib/completions/htpasswd.exp new file mode 100644 index 00000000..bb66d2f0 --- /dev/null +++ b/test/lib/completions/htpasswd.exp @@ -0,0 +1,32 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified { + /OLDPWD=/d + } +} + + +setup + + +assert_complete_any "htpasswd " +sync_after_int + + +assert_no_complete "htpasswd -n $::srcdir/fixtures/htpasswd/ht" +sync_after_int + + +assert_complete_dir "htpasswd" "htpasswd " $::srcdir/fixtures/htpasswd +sync_after_int + + +assert_complete_dir "foo quux" "htpasswd -D htpasswd " $::srcdir/fixtures/htpasswd +sync_after_int + + +teardown diff --git a/test/lib/completions/idn.exp b/test/lib/completions/idn.exp new file mode 100644 index 00000000..4625c7e4 --- /dev/null +++ b/test/lib/completions/idn.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "idn -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/import.exp b/test/lib/completions/import.exp new file mode 100644 index 00000000..db6845ea --- /dev/null +++ b/test/lib/completions/import.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "import " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/installpkg.exp b/test/lib/completions/installpkg.exp new file mode 100644 index 00000000..48581aa1 --- /dev/null +++ b/test/lib/completions/installpkg.exp @@ -0,0 +1,49 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +assert_complete_any "installpkg -" + + +sync_after_int + + +set test "--<TAB> should complete all long options" +set options [list --warn --md5sum --root --infobox --terse --menu --ask \ + --priority --tagfile] +assert_complete $options "installpkg --" $test + + +sync_after_int + + +set test "--root should comlete only dirs" +set dirs [split [exec bash -c "find . -type d -mindepth 1 -maxdepth 1 \ + -printf '%P/\n'"] "\n"] +assert_complete $dirs "installpkg --root " $test + + +sync_after_int + + +set test "should complete *.t\[gbxl\]z files and dirs" +set dir $::srcdir/fixtures/slackware/home +set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \ + \\( -type d -printf '%P/\\n' \\) -o \ + \\( -type f -name '*.t\[bglx\]z' -printf '%P\\n' \\)"] "\n"] +assert_complete_dir $files "installpkg " $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ionice.exp b/test/lib/completions/ionice.exp new file mode 100644 index 00000000..d0ff8b64 --- /dev/null +++ b/test/lib/completions/ionice.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ionice -" +sync_after_int + + +teardown diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp index 842501d2..864aabd6 100644 --- a/test/lib/completions/java.exp +++ b/test/lib/completions/java.exp @@ -18,14 +18,21 @@ assert_complete_any "java -" sync_after_int -assert_complete "b bashcomp.jarred toplevel" "java " +assert_complete "b bashcomp.jarred c. toplevel" "java " sync_after_int assert_complete "bashcomp.jarred toplevel" \ - "java -cp $::srcdir/fixtures/java/bashcomp.jar " + "java -classpath $::srcdir/fixtures/java/bashcomp.jar " + + +sync_after_int + + +assert_complete "bashcomp.jarred d toplevel" \ + "java -cp $::srcdir/fixtures/java/bashcomp.jar:$::srcdir/fixtures/java/a/c " sync_after_int diff --git a/test/lib/completions/javadoc.exp b/test/lib/completions/javadoc.exp index 0af8a3da..79e86138 100644 --- a/test/lib/completions/javadoc.exp +++ b/test/lib/completions/javadoc.exp @@ -12,8 +12,14 @@ setup assert_complete_any "javadoc " +sync_after_int + + +assert_complete {"bar bar.d/" foo.d/} "javadoc -linkoffline $::srcdir/fixtures/shared/default/" +sync_after_int +assert_complete {"bar bar.d/" foo.d/} "javadoc -nodeprecated -linkoffline foo $::srcdir/fixtures/shared/default/" sync_after_int diff --git a/test/lib/completions/jps.exp b/test/lib/completions/jps.exp new file mode 100644 index 00000000..62d5d710 --- /dev/null +++ b/test/lib/completions/jps.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "jps -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/kcov.exp b/test/lib/completions/kcov.exp new file mode 100644 index 00000000..c39f53e7 --- /dev/null +++ b/test/lib/completions/kcov.exp @@ -0,0 +1,27 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "kcov " + + +sync_after_int + + +set test "--exclude-patter<TAB> should complete \"--exclude-pattern=\"" +assert_complete "--exclude-pattern=" "kcov --exclude-patter" $test -nospace + + +sync_after_int + + +teardown diff --git a/test/lib/completions/kill.exp b/test/lib/completions/kill.exp index 1e80fe69..bc07bc48 100644 --- a/test/lib/completions/kill.exp +++ b/test/lib/completions/kill.exp @@ -12,14 +12,16 @@ setup assert_complete_any "kill 1" - - sync_after_int -assert_complete [get_signals] "kill -" +assert_complete [get_signals] "kill -s " +sync_after_int +set expected [get_signals -] +lappend expected "-l" "-s" +assert_complete [lsort -unique $expected] "kill -" sync_after_int diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index ae8b3d60..1ee3ade8 100644 --- a/test/lib/completions/killall.exp +++ b/test/lib/completions/killall.exp @@ -17,7 +17,7 @@ assert_complete_any "killall " sync_after_int -assert_complete [get_signals] "killall -" +assert_complete [get_signals -] "killall -" sync_after_int diff --git a/test/lib/completions/l2ping.exp b/test/lib/completions/l2ping.exp new file mode 100644 index 00000000..de8c58c1 --- /dev/null +++ b/test/lib/completions/l2ping.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "l2ping -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/lastlog.exp b/test/lib/completions/lastlog.exp new file mode 100644 index 00000000..74d75553 --- /dev/null +++ b/test/lib/completions/lastlog.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lastlog -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapadd.exp b/test/lib/completions/ldapadd.exp new file mode 100644 index 00000000..bc066ab6 --- /dev/null +++ b/test/lib/completions/ldapadd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapadd -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapcompare.exp b/test/lib/completions/ldapcompare.exp new file mode 100644 index 00000000..c693f703 --- /dev/null +++ b/test/lib/completions/ldapcompare.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapcompare -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapdelete.exp b/test/lib/completions/ldapdelete.exp new file mode 100644 index 00000000..cc20d0e7 --- /dev/null +++ b/test/lib/completions/ldapdelete.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapdelete -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapmodrdn.exp b/test/lib/completions/ldapmodrdn.exp new file mode 100644 index 00000000..3ae6c399 --- /dev/null +++ b/test/lib/completions/ldapmodrdn.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapmodrdn -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldappasswd.exp b/test/lib/completions/ldappasswd.exp new file mode 100644 index 00000000..2dd49393 --- /dev/null +++ b/test/lib/completions/ldappasswd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldappasswd -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapsearch.exp b/test/lib/completions/ldapsearch.exp new file mode 100644 index 00000000..92394ecd --- /dev/null +++ b/test/lib/completions/ldapsearch.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapsearch -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapvi.exp b/test/lib/completions/ldapvi.exp new file mode 100644 index 00000000..54c62772 --- /dev/null +++ b/test/lib/completions/ldapvi.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapvi -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ldapwhoami.exp b/test/lib/completions/ldapwhoami.exp new file mode 100644 index 00000000..7be41740 --- /dev/null +++ b/test/lib/completions/ldapwhoami.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ldapwhoami -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/lpq.exp b/test/lib/completions/lpq.exp new file mode 100644 index 00000000..41fdb216 --- /dev/null +++ b/test/lib/completions/lpq.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lpq " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/lpr.exp b/test/lib/completions/lpr.exp new file mode 100644 index 00000000..1ec46844 --- /dev/null +++ b/test/lib/completions/lpr.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lpr " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/lvchange.exp b/test/lib/completions/lvchange.exp index 6587a260..2240e5eb 100644 --- a/test/lib/completions/lvchange.exp +++ b/test/lib/completions/lvchange.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvchange --" +if {[assert_exec {lvchange --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvchange --" +} sync_after_int diff --git a/test/lib/completions/lvcreate.exp b/test/lib/completions/lvcreate.exp index 91cb0d81..678ac1be 100644 --- a/test/lib/completions/lvcreate.exp +++ b/test/lib/completions/lvcreate.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvcreate --" +if {[assert_exec {lvcreate --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvcreate --" +} sync_after_int diff --git a/test/lib/completions/lvdisplay.exp b/test/lib/completions/lvdisplay.exp index 6fa9c294..5e8c3210 100644 --- a/test/lib/completions/lvdisplay.exp +++ b/test/lib/completions/lvdisplay.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvdisplay --" +if {[assert_exec {lvdisplay --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvdisplay --" +} sync_after_int diff --git a/test/lib/completions/lvextend.exp b/test/lib/completions/lvextend.exp index ded34695..7c0e329e 100644 --- a/test/lib/completions/lvextend.exp +++ b/test/lib/completions/lvextend.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvextend --" +if {[assert_exec {lvextend --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvextend --" +} sync_after_int diff --git a/test/lib/completions/lvmdiskscan.exp b/test/lib/completions/lvmdiskscan.exp index 6553865f..30c73c5c 100644 --- a/test/lib/completions/lvmdiskscan.exp +++ b/test/lib/completions/lvmdiskscan.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvmdiskscan --" +if {[assert_exec {lvmdiskscan --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvmdiskscan --" +} sync_after_int diff --git a/test/lib/completions/lvreduce.exp b/test/lib/completions/lvreduce.exp index e2708f89..b9904fef 100644 --- a/test/lib/completions/lvreduce.exp +++ b/test/lib/completions/lvreduce.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvreduce --" +if {[assert_exec {lvreduce --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvreduce --" +} sync_after_int diff --git a/test/lib/completions/lvremove.exp b/test/lib/completions/lvremove.exp index 8ca1517b..0f41d8dc 100644 --- a/test/lib/completions/lvremove.exp +++ b/test/lib/completions/lvremove.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvremove --" +if {[assert_exec {lvremove --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvremove --" +} sync_after_int diff --git a/test/lib/completions/lvrename.exp b/test/lib/completions/lvrename.exp index 17179ce9..77d6c5e0 100644 --- a/test/lib/completions/lvrename.exp +++ b/test/lib/completions/lvrename.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvrename --" +if {[assert_exec {lvrename --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvrename --" +} sync_after_int diff --git a/test/lib/completions/lvresize.exp b/test/lib/completions/lvresize.exp index 2b3e1044..a0e8f99e 100644 --- a/test/lib/completions/lvresize.exp +++ b/test/lib/completions/lvresize.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvresize --" +if {[assert_exec {lvresize --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvresize --" +} sync_after_int diff --git a/test/lib/completions/lvs.exp b/test/lib/completions/lvs.exp index e531f7e9..c46a8153 100644 --- a/test/lib/completions/lvs.exp +++ b/test/lib/completions/lvs.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvs --" +if {[assert_exec {lvs --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvs --" +} sync_after_int diff --git a/test/lib/completions/lvscan.exp b/test/lib/completions/lvscan.exp index 7b09e5e1..60effb5d 100644 --- a/test/lib/completions/lvscan.exp +++ b/test/lib/completions/lvscan.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "lvscan --" +if {[assert_exec {lvscan --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "lvscan --" +} sync_after_int diff --git a/test/lib/completions/makepkg.exp b/test/lib/completions/makepkg.exp new file mode 100644 index 00000000..56e06339 --- /dev/null +++ b/test/lib/completions/makepkg.exp @@ -0,0 +1,28 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "makepkg -" + + +sync_after_int + + +set test "--<TAB> should complete all long options" +set options [list --linkadd --prepend --chown] +assert_complete $options "makepkg --" $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mdadm.exp b/test/lib/completions/mdadm.exp new file mode 100644 index 00000000..6559aa20 --- /dev/null +++ b/test/lib/completions/mdadm.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "mdadm " +sync_after_int + + +teardown diff --git a/test/lib/completions/mdtool.exp b/test/lib/completions/mdtool.exp new file mode 100644 index 00000000..076cb17a --- /dev/null +++ b/test/lib/completions/mdtool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "mdtool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/medusa.exp b/test/lib/completions/medusa.exp new file mode 100644 index 00000000..6ad2fdc3 --- /dev/null +++ b/test/lib/completions/medusa.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "medusa -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mii-diag.exp b/test/lib/completions/mii-diag.exp new file mode 100644 index 00000000..952ff632 --- /dev/null +++ b/test/lib/completions/mii-diag.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "mii-diag " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mii-tool.exp b/test/lib/completions/mii-tool.exp new file mode 100644 index 00000000..03827edd --- /dev/null +++ b/test/lib/completions/mii-tool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "mii-tool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp index 8d8c881d..44e87cee 100644 --- a/test/lib/completions/mkdir.exp +++ b/test/lib/completions/mkdir.exp @@ -23,4 +23,11 @@ assert_complete {"bar bar.d/" foo.d/} "mkdir $::srcdir/fixtures/shared/default/" sync_after_int +# No subdirs in foo.d and should not complete files in it (_longopt()). +assert_no_complete "mkdir $::srcdir/fixtures/shared/default/foo.d/" + + +sync_after_int + + teardown diff --git a/test/lib/completions/monodevelop.exp b/test/lib/completions/monodevelop.exp new file mode 100644 index 00000000..0bfe788e --- /dev/null +++ b/test/lib/completions/monodevelop.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "monodevelop " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp index c99d6058..1298f36f 100644 --- a/test/lib/completions/mount.exp +++ b/test/lib/completions/mount.exp @@ -30,7 +30,7 @@ proc setup {} { proc teardown {} { teardown_dummy_mnt - assert_env_unmodified + assert_env_unmodified {/OLDPWD/d} } @@ -49,6 +49,13 @@ assert_complete_any "mount -t " sync_after_int +set test "mount /dev/sda1 def should complete directory name" +assert_complete_dir "default/" "mount /dev/sda1 def" $::srcdir/fixtures/shared $test -nospace + + +sync_after_int + + set test "Check completing nfs mounts" set expected [list /test/path /test/path2 /second/path] set cmd "mount mocksrv:/" diff --git a/test/lib/completions/msynctool.exp b/test/lib/completions/msynctool.exp new file mode 100644 index 00000000..cb238d9f --- /dev/null +++ b/test/lib/completions/msynctool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "msynctool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/mutt.exp b/test/lib/completions/mutt.exp index 8cb8b0c6..1f4425e2 100644 --- a/test/lib/completions/mutt.exp +++ b/test/lib/completions/mutt.exp @@ -1,10 +1,15 @@ proc setup {} { save_env + assert_bash_exec {OLDHOME=$HOME ; HOME=$SRCDIRABS/fixtures/mutt} } proc teardown {} { - assert_env_unmodified {/OLDPWD=/d} + assert_bash_exec {HOME=$OLDHOME} + assert_env_unmodified { + /OLDPWD=/d + /OLDHOME=/d + } } @@ -19,15 +24,20 @@ sync_after_int set test "mutt should complete mailboxes" set expected {foo/ bar/ muttrc} -assert_complete_dir $expected "mutt -F muttrc -f =" $::srcdir/fixtures/mutt +assert_complete_dir $expected "mutt -F muttrc -f =" $::srcdir/fixtures/mutt $test set test "mutt should complete aliases" set expected {a1 a2} -assert_complete_dir $expected "mutt -F muttrc -A " $::srcdir/fixtures/mutt +assert_complete_dir $expected "mutt -F muttrc -A " $::srcdir/fixtures/mutt $test sync_after_int +set expected "$::srcdirabs/fixtures/mutt/muttrc $::srcdirabs/fixtures/mutt/bar/muttrc_b $::srcdirabs/fixtures/mutt/foo/muttrc_f" +assert_bash_list $expected { _muttconffiles "$HOME/muttrc" "$HOME/muttrc" } "find muttrcs recursively" +sync_after_int + + teardown diff --git a/test/lib/completions/mysql.exp b/test/lib/completions/mysql.exp new file mode 100644 index 00000000..62a64fc2 --- /dev/null +++ b/test/lib/completions/mysql.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "mysql --" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/newusers.exp b/test/lib/completions/newusers.exp new file mode 100644 index 00000000..a1928120 --- /dev/null +++ b/test/lib/completions/newusers.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "newusers " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/nslookup.exp b/test/lib/completions/nslookup.exp new file mode 100644 index 00000000..20b84451 --- /dev/null +++ b/test/lib/completions/nslookup.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "nslookup -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/openssl.exp b/test/lib/completions/openssl.exp index 25fc1367..d1357002 100644 --- a/test/lib/completions/openssl.exp +++ b/test/lib/completions/openssl.exp @@ -25,4 +25,8 @@ expect { sync_after_int +assert_complete_any "openssl pkey -cipher " +sync_after_int + + teardown diff --git a/test/lib/completions/passwd.exp b/test/lib/completions/passwd.exp new file mode 100644 index 00000000..df2945b8 --- /dev/null +++ b/test/lib/completions/passwd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "passwd " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/perl.exp b/test/lib/completions/perl.exp index 8cd6f957..f3a51841 100644 --- a/test/lib/completions/perl.exp +++ b/test/lib/completions/perl.exp @@ -86,7 +86,7 @@ set test "- should complete options" set options { -0 -a -c -C -d -D -e -F -h -i -I -l -m -M -n -p -P -s -S -T -u -U -v -V -w -W -x -X } -assert_complete $options "perl -" +assert_complete $options "perl -" $test sync_after_int diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp index dc1c79c8..9a9d9fbf 100644 --- a/test/lib/completions/perldoc.exp +++ b/test/lib/completions/perldoc.exp @@ -32,7 +32,7 @@ set test "- should complete options" set options { -h -v -t -u -m -l -F -X -f -q } -assert_complete $options "perldoc -" +assert_complete $options "perldoc -" $test sync_after_int diff --git a/test/lib/completions/phing.exp b/test/lib/completions/phing.exp new file mode 100644 index 00000000..f064ea4a --- /dev/null +++ b/test/lib/completions/phing.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "phing -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/pinfo.exp b/test/lib/completions/pinfo.exp new file mode 100644 index 00000000..3af44044 --- /dev/null +++ b/test/lib/completions/pinfo.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pinfo " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ping.exp b/test/lib/completions/ping.exp index 3e419966..9ef7f2fd 100644 --- a/test/lib/completions/ping.exp +++ b/test/lib/completions/ping.exp @@ -12,8 +12,9 @@ setup assert_complete_any "ping " +sync_after_int - +assert_complete_any "ping -" sync_after_int diff --git a/test/lib/completions/pkgtool.exp b/test/lib/completions/pkgtool.exp new file mode 100644 index 00000000..c071ecd4 --- /dev/null +++ b/test/lib/completions/pkgtool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pkgtool -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/postcat.exp b/test/lib/completions/postcat.exp new file mode 100644 index 00000000..78636676 --- /dev/null +++ b/test/lib/completions/postcat.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "postcat " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/postconf.exp b/test/lib/completions/postconf.exp new file mode 100644 index 00000000..40349061 --- /dev/null +++ b/test/lib/completions/postconf.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "postconf p" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/postfix.exp b/test/lib/completions/postfix.exp new file mode 100644 index 00000000..d1cb7e80 --- /dev/null +++ b/test/lib/completions/postfix.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "postfix " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/postmap.exp b/test/lib/completions/postmap.exp new file mode 100644 index 00000000..af31061f --- /dev/null +++ b/test/lib/completions/postmap.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "postmap " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/postsuper.exp b/test/lib/completions/postsuper.exp new file mode 100644 index 00000000..145895e2 --- /dev/null +++ b/test/lib/completions/postsuper.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "postsuper " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/prelink.exp b/test/lib/completions/prelink.exp new file mode 100644 index 00000000..4a493667 --- /dev/null +++ b/test/lib/completions/prelink.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "prelink " +sync_after_int + +assert_complete_any "prelink -" +sync_after_int + + +teardown diff --git a/test/lib/completions/protoc.exp b/test/lib/completions/protoc.exp new file mode 100644 index 00000000..caeb8274 --- /dev/null +++ b/test/lib/completions/protoc.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "protoc " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/puppet.exp b/test/lib/completions/puppet.exp new file mode 100644 index 00000000..7b7da3e7 --- /dev/null +++ b/test/lib/completions/puppet.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "puppet " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/pvchange.exp b/test/lib/completions/pvchange.exp index a43ae9cd..f317b52f 100644 --- a/test/lib/completions/pvchange.exp +++ b/test/lib/completions/pvchange.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "pvchange --" +if {[assert_exec {pvchange --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "pvchange --" +} sync_after_int diff --git a/test/lib/completions/pvcreate.exp b/test/lib/completions/pvcreate.exp index 6bc9d4eb..6e36b368 100644 --- a/test/lib/completions/pvcreate.exp +++ b/test/lib/completions/pvcreate.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "pvcreate --" +if {[assert_exec {pvcreate --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "pvcreate --" +} sync_after_int diff --git a/test/lib/completions/pvdisplay.exp b/test/lib/completions/pvdisplay.exp index b9db558b..7b1df0c3 100644 --- a/test/lib/completions/pvdisplay.exp +++ b/test/lib/completions/pvdisplay.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "pvdisplay --" +if {[assert_exec {pvdisplay --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "pvdisplay --" +} sync_after_int diff --git a/test/lib/completions/pvremove.exp b/test/lib/completions/pvremove.exp index 1febcf37..6d655e79 100644 --- a/test/lib/completions/pvremove.exp +++ b/test/lib/completions/pvremove.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "pvremove --" +if {[assert_exec {pvremove --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "pvremove --" +} sync_after_int diff --git a/test/lib/completions/pvs.exp b/test/lib/completions/pvs.exp index e50501a3..195665fd 100644 --- a/test/lib/completions/pvs.exp +++ b/test/lib/completions/pvs.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "pvs --" +if {[assert_exec {pvs --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "pvs --" +} sync_after_int diff --git a/test/lib/completions/pwck.exp b/test/lib/completions/pwck.exp new file mode 100644 index 00000000..e7c5706c --- /dev/null +++ b/test/lib/completions/pwck.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pwck " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/pwdx.exp b/test/lib/completions/pwdx.exp new file mode 100644 index 00000000..314623bd --- /dev/null +++ b/test/lib/completions/pwdx.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pwdx " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/pwgen.exp b/test/lib/completions/pwgen.exp new file mode 100644 index 00000000..b8882b68 --- /dev/null +++ b/test/lib/completions/pwgen.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pwgen -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/qemu.exp b/test/lib/completions/qemu.exp new file mode 100644 index 00000000..cd3d5938 --- /dev/null +++ b/test/lib/completions/qemu.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "qemu " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/quota.exp b/test/lib/completions/quota.exp new file mode 100644 index 00000000..1eb9f161 --- /dev/null +++ b/test/lib/completions/quota.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "quota " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/quotacheck.exp b/test/lib/completions/quotacheck.exp new file mode 100644 index 00000000..4200da32 --- /dev/null +++ b/test/lib/completions/quotacheck.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "quotacheck " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/quotaon.exp b/test/lib/completions/quotaon.exp new file mode 100644 index 00000000..4acc70e1 --- /dev/null +++ b/test/lib/completions/quotaon.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "quotaon " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/rdesktop.exp b/test/lib/completions/rdesktop.exp new file mode 100644 index 00000000..32544941 --- /dev/null +++ b/test/lib/completions/rdesktop.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rdesktop -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/removepkg.exp b/test/lib/completions/removepkg.exp index 882f1e70..b7cf4b1c 100644 --- a/test/lib/completions/removepkg.exp +++ b/test/lib/completions/removepkg.exp @@ -4,14 +4,29 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified {/ROOT=/d} } setup -assert_complete_any "removepkg " +set test "-<TAB> should complete all options" +set options [list -copy -keep -preserve -warn] +assert_complete $options "removepkg -" $test + + +sync_after_int + + +set test "should complete files in \$ROOT/var/log/packages/" +# set env(ROOT) [file normalize $::srcdir/fixtures/slackware] +# set dir $env(ROOT)/var/log/packages/ +set root [file normalize $::srcdir/fixtures/slackware] +set dir $root/var/log/packages/ +assert_bash_exec "ROOT=$root" +set files [split [exec bash -c "cd $dir && ls"] "\n"] +assert_complete $files "removepkg " $test sync_after_int diff --git a/test/lib/completions/reptyr.exp b/test/lib/completions/reptyr.exp new file mode 100644 index 00000000..35ccb91c --- /dev/null +++ b/test/lib/completions/reptyr.exp @@ -0,0 +1,22 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "reptyr -" +sync_after_int + + +assert_complete_any "reptyr " +sync_after_int + + +teardown diff --git a/test/lib/completions/rfcomm.exp b/test/lib/completions/rfcomm.exp new file mode 100644 index 00000000..b449134c --- /dev/null +++ b/test/lib/completions/rfcomm.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rfcomm " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ri.exp b/test/lib/completions/ri.exp index cd138ea0..e6661d1b 100644 --- a/test/lib/completions/ri.exp +++ b/test/lib/completions/ri.exp @@ -11,7 +11,7 @@ proc teardown {} { setup -assert_complete_any "ri " +assert_complete_any "ri RI" sync_after_int diff --git a/test/lib/completions/route.exp b/test/lib/completions/route.exp new file mode 100644 index 00000000..76e1b5e0 --- /dev/null +++ b/test/lib/completions/route.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "route " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/rpm2tgz.exp b/test/lib/completions/rpm2tgz.exp new file mode 100644 index 00000000..eb597982 --- /dev/null +++ b/test/lib/completions/rpm2tgz.exp @@ -0,0 +1,31 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +assert_complete_any "rpm2tgz -" + + +sync_after_int + + +set test "should complete *.rpm files and dirs" +set dir $::srcdir/fixtures/slackware/home +set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \ + \\( -type d -printf '%P/\\n' \\) -o \ + \\( -type f -name '*.rpm' -printf '%P\\n' \\)"] "\n"] +assert_complete_dir $files "rpm2tgz " $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/rpmbuild.exp b/test/lib/completions/rpmbuild.exp new file mode 100644 index 00000000..4058d722 --- /dev/null +++ b/test/lib/completions/rpmbuild.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "rpmbuild -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/rsync.exp b/test/lib/completions/rsync.exp index 221d090b..42b7af8e 100644 --- a/test/lib/completions/rsync.exp +++ b/test/lib/completions/rsync.exp @@ -12,8 +12,14 @@ setup assert_complete_any "rsync " +sync_after_int + + +assert_complete "rsh ssh" "rsync --rsh " +sync_after_int +assert_complete "rsh ssh" "rsync --rsh=" sync_after_int diff --git a/test/lib/completions/sbopkg.exp b/test/lib/completions/sbopkg.exp new file mode 100644 index 00000000..c4dbfe26 --- /dev/null +++ b/test/lib/completions/sbopkg.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "sbopkg -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp index e6cbf8e3..7cc6eb07 100644 --- a/test/lib/completions/scp.exp +++ b/test/lib/completions/scp.exp @@ -24,7 +24,7 @@ set host bash_completion # Retrieving home directory (host_pwd) from ssh-host `bash_completion' # yields error? -if { +if { [catch { exec -- ssh -o "Batchmode yes" -o "ConnectTimeout 1" $host pwd 2>> /dev/null } host_pwd] @@ -64,7 +64,7 @@ foreach host [get_hosts] { lappend expected blah: doo: gee: hus: ike: # Append local filenames lappend expected config known_hosts "spaced\\ \\ conf" -assert_complete $expected "scp -F config " +assert_complete $expected "scp -F config " $test sync_after_int @@ -104,11 +104,8 @@ if {[match_items [lsort -unique $expected] -bash-sort]} { expect { -re /@ { pass "$test" } -re eof { unresolved "eof" } + default { fail "$test" } } -} else { - # Expected failure (known bug) because of bash-4 bug in quoted words: - # http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html - if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"} } sync_after_int assert_bash_exec {cd "$TESTDIR"} diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp index e5bc4c15..5e585179 100644 --- a/test/lib/completions/screen.exp +++ b/test/lib/completions/screen.exp @@ -12,15 +12,19 @@ setup assert_complete_any "screen -" - - sync_after_int assert_complete {bar "bar bar.d/" foo foo.d/} \ "screen -c $::srcdir/fixtures/shared/default/" "-c should complete files/dirs" +sync_after_int + + +assert_complete_any "screen cat" +sync_after_int +assert_complete_any "screen -T foo cat" sync_after_int diff --git a/test/lib/completions/sdptool.exp b/test/lib/completions/sdptool.exp new file mode 100644 index 00000000..c46a1fa2 --- /dev/null +++ b/test/lib/completions/sdptool.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "sdptool " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/setquota.exp b/test/lib/completions/setquota.exp new file mode 100644 index 00000000..d169e1ad --- /dev/null +++ b/test/lib/completions/setquota.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "setquota " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/slackpkg.exp b/test/lib/completions/slackpkg.exp new file mode 100644 index 00000000..150f03fc --- /dev/null +++ b/test/lib/completions/slackpkg.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "slackpkg -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/slapt-get.exp b/test/lib/completions/slapt-get.exp new file mode 100644 index 00000000..70afc666 --- /dev/null +++ b/test/lib/completions/slapt-get.exp @@ -0,0 +1,46 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "slapt-get -" + + +sync_after_int + + +set test "--up<TAB> should complete \"--update --upgrade\"" +assert_complete "--update --upgrade" "slapt-get --up" $test + + +sync_after_int + + + +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 new file mode 100644 index 00000000..9410f9c1 --- /dev/null +++ b/test/lib/completions/slapt-src.exp @@ -0,0 +1,49 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "slapt-src -" + + +sync_after_int + + +set test "--bu<TAB> should complete \"--build\"" +assert_complete "--build" "slapt-src --bu" $test + + +sync_after_int + + +set test "--ins<TAB> should complete \"--install\"" +assert_complete "--install" "slapt-src --ins" $test + + +sync_after_int + + +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/smbcacls.exp b/test/lib/completions/smbcacls.exp new file mode 100644 index 00000000..d501f825 --- /dev/null +++ b/test/lib/completions/smbcacls.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbcacls -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbclient.exp b/test/lib/completions/smbclient.exp new file mode 100644 index 00000000..0fb8e2da --- /dev/null +++ b/test/lib/completions/smbclient.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbclient -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbcquotas.exp b/test/lib/completions/smbcquotas.exp new file mode 100644 index 00000000..24be2f60 --- /dev/null +++ b/test/lib/completions/smbcquotas.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbcquotas -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbget.exp b/test/lib/completions/smbget.exp new file mode 100644 index 00000000..938cd0e5 --- /dev/null +++ b/test/lib/completions/smbget.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbget -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbpasswd.exp b/test/lib/completions/smbpasswd.exp new file mode 100644 index 00000000..b6e86bbc --- /dev/null +++ b/test/lib/completions/smbpasswd.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbpasswd -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbtar.exp b/test/lib/completions/smbtar.exp new file mode 100644 index 00000000..e0d58f5f --- /dev/null +++ b/test/lib/completions/smbtar.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbtar -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/smbtree.exp b/test/lib/completions/smbtree.exp new file mode 100644 index 00000000..b234e443 --- /dev/null +++ b/test/lib/completions/smbtree.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "smbtree -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ssh-copy-id.exp b/test/lib/completions/ssh-copy-id.exp new file mode 100644 index 00000000..e8b643fd --- /dev/null +++ b/test/lib/completions/ssh-copy-id.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ssh-copy-id -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/stream.exp b/test/lib/completions/stream.exp new file mode 100644 index 00000000..8cbda602 --- /dev/null +++ b/test/lib/completions/stream.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "stream " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp index d6bbbbb6..6108ddce 100644 --- a/test/lib/completions/sudo.exp +++ b/test/lib/completions/sudo.exp @@ -24,4 +24,63 @@ assert_complete_dir fixtures/ "sudo sh fix" $::srcdir "" -nospace sync_after_int +# test that `mount` and `sudo mount` behave the same way +set test "sudo mount /dev/sda1 def should complete directory name" +assert_complete_dir "default/" "sudo mount /dev/sda1 def" $::srcdir/fixtures/shared $test -nospace + + +sync_after_int + + +# 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} { + assert_complete $fulluser "sudo chown $partuser" + sync_after_int + + assert_complete $fulluser:$fullgroup "sudo chown $fulluser:$partgroup" + sync_after_int + + assert_complete "dot.user:$fullgroup" "sudo chown dot.user:$partgroup" + sync_after_int + + 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 + } + + # Check that we give up in degenerate cases instead of spewing various junk. + + assert_no_complete "sudo chown $fulluser\\\\:$partgroup" + sync_after_int + + assert_no_complete "sudo chown $fulluser\\\\\\:$partgroup" + sync_after_int + + assert_no_complete "sudo chown $fulluser\\\\\\\\:$partgroup" + sync_after_int + + # Colons in user/groupnames are not usually allowed. + assert_no_complete "sudo chown foo:bar:$partgroup" + sync_after_int +} + + teardown diff --git a/test/lib/completions/tcpdump.exp b/test/lib/completions/tcpdump.exp new file mode 100644 index 00000000..79158abf --- /dev/null +++ b/test/lib/completions/tcpdump.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "tcpdump -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/time.exp b/test/lib/completions/time.exp index 3bed4fdf..d052458c 100644 --- a/test/lib/completions/time.exp +++ b/test/lib/completions/time.exp @@ -4,7 +4,7 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified {/OLDPWD=/d} } @@ -17,4 +17,20 @@ assert_complete_any "time set" sync_after_int +set test "-p find -typ should complete find's options" +assert_complete "-type" "time -p find -typ" $test + + +sync_after_int + + +set test "it should be possible to complete file paths" +set dir $::srcdir/fixtures/shared +set files [split [exec bash -c "cd $dir/bin && ls -p"] "\n"] +assert_complete_dir $files "time ./bin/" $dir $test + + +sync_after_int + + teardown diff --git a/test/lib/completions/tracepath.exp b/test/lib/completions/tracepath.exp new file mode 100644 index 00000000..33b32567 --- /dev/null +++ b/test/lib/completions/tracepath.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "tracepath " +sync_after_int + +assert_complete_any "tracepath -" +sync_after_int + + +teardown diff --git a/test/lib/completions/upgradepkg.exp b/test/lib/completions/upgradepkg.exp new file mode 100644 index 00000000..860dde9e --- /dev/null +++ b/test/lib/completions/upgradepkg.exp @@ -0,0 +1,39 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +assert_complete_any "upgradepkg -" + + +sync_after_int + + +set test "--<TAB> should complete all long options" +set options [list --dry-run --install-new --reinstall --verbose] +assert_complete $options "upgradepkg --" $test + + +sync_after_int + + +set test "should complete *.t\[gbxl\]z files and dirs" +set dir $::srcdir/fixtures/slackware/home +set files [split [exec bash -c "cd $dir && find . -mindepth 1 -maxdepth 1 \ + \\( -type d -printf '%P/\\n' \\) -o \ + \\( -type f -name '*.t\[bglx\]z' -printf '%P\\n' \\)"] "\n"] +assert_complete_dir $files "upgradepkg " $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/vgcfgbackup.exp b/test/lib/completions/vgcfgbackup.exp index b7e509a2..14162ee0 100644 --- a/test/lib/completions/vgcfgbackup.exp +++ b/test/lib/completions/vgcfgbackup.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgcfgbackup -" +if {[assert_exec {vgcfgbackup --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgcfgbackup -" +} sync_after_int diff --git a/test/lib/completions/vgcfgrestore.exp b/test/lib/completions/vgcfgrestore.exp index e40cd213..2cf5f1ca 100644 --- a/test/lib/completions/vgcfgrestore.exp +++ b/test/lib/completions/vgcfgrestore.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgcfgrestore -" +if {[assert_exec {vgcfgrestore --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgcfgrestore -" +} sync_after_int diff --git a/test/lib/completions/vgck.exp b/test/lib/completions/vgck.exp index b4d58aec..b2c86da8 100644 --- a/test/lib/completions/vgck.exp +++ b/test/lib/completions/vgck.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgck -" +if {[assert_exec {vgck --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgck -" +} sync_after_int diff --git a/test/lib/completions/vgconvert.exp b/test/lib/completions/vgconvert.exp index 362c44b6..f432229e 100644 --- a/test/lib/completions/vgconvert.exp +++ b/test/lib/completions/vgconvert.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgconvert -" +if {[assert_exec {vgconvert --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgconvert -" +} sync_after_int diff --git a/test/lib/completions/vgdisplay.exp b/test/lib/completions/vgdisplay.exp index 6a8ed84d..5fd20596 100644 --- a/test/lib/completions/vgdisplay.exp +++ b/test/lib/completions/vgdisplay.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgdisplay -" +if {[assert_exec {vgdisplay --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgdisplay -" +} sync_after_int diff --git a/test/lib/completions/vgexport.exp b/test/lib/completions/vgexport.exp index 2900960f..e6e45d00 100644 --- a/test/lib/completions/vgexport.exp +++ b/test/lib/completions/vgexport.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgexport -" +if {[assert_exec {vgexport --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgexport -" +} sync_after_int diff --git a/test/lib/completions/vgextend.exp b/test/lib/completions/vgextend.exp index 3c46a8f0..18dc2016 100644 --- a/test/lib/completions/vgextend.exp +++ b/test/lib/completions/vgextend.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgextend -" +if {[assert_exec {vgextend --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgextend -" +} sync_after_int diff --git a/test/lib/completions/vgimport.exp b/test/lib/completions/vgimport.exp index ed04e282..f4c1f833 100644 --- a/test/lib/completions/vgimport.exp +++ b/test/lib/completions/vgimport.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgimport -" +if {[assert_exec {vgimport --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgimport -" +} sync_after_int diff --git a/test/lib/completions/vgmerge.exp b/test/lib/completions/vgmerge.exp index a4f8833b..a8366848 100644 --- a/test/lib/completions/vgmerge.exp +++ b/test/lib/completions/vgmerge.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgmerge -" +if {[assert_exec {vgmerge --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgmerge -" +} sync_after_int diff --git a/test/lib/completions/vgmknodes.exp b/test/lib/completions/vgmknodes.exp index 5c9feeb3..b8c3d57f 100644 --- a/test/lib/completions/vgmknodes.exp +++ b/test/lib/completions/vgmknodes.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgmknodes -" +if {[assert_exec {vgmknodes --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgmknodes -" +} sync_after_int diff --git a/test/lib/completions/vgreduce.exp b/test/lib/completions/vgreduce.exp index f6af3150..fc349680 100644 --- a/test/lib/completions/vgreduce.exp +++ b/test/lib/completions/vgreduce.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgreduce -" +if {[assert_exec {vgreduce --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgreduce -" +} sync_after_int diff --git a/test/lib/completions/vgremove.exp b/test/lib/completions/vgremove.exp index 0dc5eda8..0ec1011f 100644 --- a/test/lib/completions/vgremove.exp +++ b/test/lib/completions/vgremove.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgremove -" +if {[assert_exec {vgremove --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgremove -" +} sync_after_int diff --git a/test/lib/completions/vgrename.exp b/test/lib/completions/vgrename.exp index 81438631..62e7d3e6 100644 --- a/test/lib/completions/vgrename.exp +++ b/test/lib/completions/vgrename.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgrename -" +if {[assert_exec {vgrename --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgrename -" +} sync_after_int diff --git a/test/lib/completions/vgs.exp b/test/lib/completions/vgs.exp index 22ab176b..8a6cf650 100644 --- a/test/lib/completions/vgs.exp +++ b/test/lib/completions/vgs.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgs -" +if {[assert_exec {vgs --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgs -" +} sync_after_int diff --git a/test/lib/completions/vgscan.exp b/test/lib/completions/vgscan.exp index ae8168c8..a26838fc 100644 --- a/test/lib/completions/vgscan.exp +++ b/test/lib/completions/vgscan.exp @@ -11,7 +11,9 @@ proc teardown {} { setup -assert_complete_any "vgscan -" +if {[assert_exec {vgscan --help} "" "" "untested"]} { # may fail as non-root + assert_complete_any "vgscan -" +} sync_after_int diff --git a/test/lib/completions/vipw.exp b/test/lib/completions/vipw.exp new file mode 100644 index 00000000..c29ad9b1 --- /dev/null +++ b/test/lib/completions/vipw.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "vipw -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/watch.exp b/test/lib/completions/watch.exp new file mode 100644 index 00000000..02ae8f1b --- /dev/null +++ b/test/lib/completions/watch.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "watch -" +sync_after_int + + +teardown diff --git a/test/lib/completions/xgamma.exp b/test/lib/completions/xgamma.exp new file mode 100644 index 00000000..c4c2228e --- /dev/null +++ b/test/lib/completions/xgamma.exp @@ -0,0 +1,21 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +set test "-gam<TAB> should complete \"-gamma\"" +assert_complete "-gamma" "xgamma -gam" $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/xhost.exp b/test/lib/completions/xhost.exp index 82e2e9c6..02aa4cb2 100644 --- a/test/lib/completions/xhost.exp +++ b/test/lib/completions/xhost.exp @@ -30,7 +30,7 @@ foreach h [get_hosts] { lappend hosts $h } } -assert_complete $hosts "xhost $char" $test +assert_complete $hosts "xhost $char" $test -expect-cmd-minus "$char" sync_after_int @@ -58,7 +58,7 @@ foreach h [get_hosts] { lappend hosts "+$h" } } -assert_complete $hosts "xhost +$char" +assert_complete $hosts "xhost +$char" $test -expect-cmd-minus "\+$char" sync_after_int @@ -86,7 +86,7 @@ foreach h [get_hosts] { lappend hosts "-$h" } } -assert_complete $hosts "xhost -$char" $test +assert_complete $hosts "xhost -$char" $test -expect-cmd-minus "-$char" sync_after_int diff --git a/test/lib/completions/xvnc4viewer.exp b/test/lib/completions/xvnc4viewer.exp index b10e272c..6432ed25 100644 --- a/test/lib/completions/xvnc4viewer.exp +++ b/test/lib/completions/xvnc4viewer.exp @@ -22,7 +22,7 @@ set options { -via -ViewOnly -WMDecorationHeight -WMDecorationWidth -ZlibLevel } -assert_complete $options {vncviewer -} +assert_complete $options {vncviewer -} $test sync_after_int diff --git a/test/lib/completions/xzdec.exp b/test/lib/completions/xzdec.exp new file mode 100644 index 00000000..578cba7d --- /dev/null +++ b/test/lib/completions/xzdec.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "xzdec " + + +sync_after_int + + +teardown diff --git a/test/lib/library.exp b/test/lib/library.exp index 491da212..f6e9f21a 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -155,8 +155,6 @@ proc assert_bash_list_dir {expected cmd dir test {args {}}} { # - the last whitespace is escaped, e.g. "finger foo\ " or "finger # 'foo " # -# If the entire $cmd is expected, specify `-expect-cmd-full'. -# # @param list $expected Expected completions. # @param string $cmd Command given to generate items # @param string $test Test title @@ -168,12 +166,6 @@ proc assert_bash_list_dir {expected cmd dir test {args {}}} { # Valid only if a single completion is expected. # -ltrim-colon-completions Left-trim completions with cword containing # colon (:) -# -expect-cmd-full Expect the full $cmd to be echoed. Expected is: -# -# $cmd<TAB>\n -# $expected\n -# $prompt + $cmd + longest-common-prefix-of-$expected -# # -expect-cmd-minus DWORD Expect $cmd minus DWORD to be echoed. # Expected is: # @@ -188,7 +180,6 @@ proc assert_complete {expected cmd {test ""} {args {}}} { {chunk-size.arg 20 "compare N list items at a time"} {nospace "don't expect space after completion"} {ltrim-colon-completions "left-trim completions with cword containing :"} - {expect-cmd-full "Expect full cmd after prompt"} {expect-cmd-minus.arg "" "Expect cmd minus DWORD after prompt"} }] if {[llength $expected] == 0} { @@ -210,7 +201,6 @@ proc assert_complete_many {expected cmd {test ""} {args {}}} { {chunk-size.arg 20 "compare N list items at a time"} {nospace "don't expect space after completion"} {ltrim-colon-completions "left-trim completions with cword containing :"} - {expect-cmd-full "Expect full cmd after prompt"} {expect-cmd-minus.arg "" "Expect cmd minus CWORD after prompt"} }] if {$test == ""} {set test "$cmd should show completions"} @@ -256,7 +246,6 @@ proc assert_complete_one {expected cmd {test ""} {args {}}} { {chunk-size.arg 20 "compare N list items at a time"} {nospace "don't expect space after completion"} {ltrim-colon-completions "left-trim completions with cword containing :"} - {expect-cmd-full "Expect full cmd after prompt"} {expect-cmd-minus.arg "" "Expect cmd minus CWORD after prompt"} }] set prompt $arg(prompt) @@ -435,13 +424,9 @@ proc _ltrim_colon_completions {cmd items dword} { set cur [lindex $words $index] } # If word-to-complete contains a colon, - # and bash-version < 4, - # or bash-version >= 4 and COMP_WORDBREAKS contains a colon + # and COMP_WORDBREAKS contains a colon if { - [string first : $cur] > -1 && ( - [lindex $::BASH_VERSINFO 0] < 4 || - ([lindex $::BASH_VERSINFO 0] >= 4 && [string first ":" $::COMP_WORDBREAKS] > -1) - ) + [string first : $cur] > -1 && [string first ":" $::COMP_WORDBREAKS] > -1 } { set dword_out $cur for {set i 0} {$i < [llength $items_out]} {incr i} { @@ -595,12 +580,13 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} { # Source/run file with additional tests if completion for the specified command -# is installed in bash. +# is installed in bash, and the command is available. # @param string $command Command to check completion availability for. # @param string $file (optional) File to source/run. Default is # "lib/completions/$cmd.exp". proc assert_source_completions {command {file ""}} { - if {[is_bash_completion_installed_for $command]} { + if {[assert_bash_type $command] + && [is_bash_completion_installed_for $command]} { if {[string length $file] == 0} { set file "$::srcdir/lib/completions/$command.exp" } @@ -633,10 +619,17 @@ proc get_known_hosts {{cword ''}} { # Get hostnames +# @param list $args Options: +# -unsorted Do not sort unique. Default is sort unique. # @return list Hostnames # @see get_known_hosts() -proc get_hosts {} { - set hosts [exec bash -c "compgen -A hostname | sort -u"] +proc get_hosts {{args {}}} { + array set arg [::cmdline::getoptions args { + {unsorted "do not sort unique"} + }] + set sort "| sort -u" + if {$arg(unsorted)} {set sort ""} + set hosts [exec bash -c "compgen -A hostname $sort"] # NOTE: Circumventing var `avahi_hosts' and appending directly to `hosts' # causes an empty element to be inserted in `hosts'. # -- FVu, Fri Jul 17 23:11:46 CEST 2009 @@ -667,8 +660,9 @@ proc get_hosts_avahi {} { # Get signals # This function is written in analogy to the bash function `_signals()' in # `bash_completion'. +# @param prefix # @return list Signals starting with `SIG', but with the `SIG' prefix removed. -proc get_signals {} { +proc get_signals {{prefix ""}} { set signals {} foreach signal [exec bash -c {compgen -A signal}] { # Does signal start with `SIG'? @@ -676,7 +670,7 @@ proc get_signals {} { # Remove `SIG' prefix set signal [string range $signal 3 end] # Add signal (with dash (-) prefix) to list - lappend signals -$signal + lappend signals $prefix$signal } } return $signals @@ -855,10 +849,8 @@ proc _save_env {{file ""}} { # Source bash_completion package proc source_bash_completion {} { - assert_bash_exec {BASH_COMPLETION_DIR=$(cd "$SRCDIR/.."; pwd)/completions} - assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$BASH_COMPLETION_DIR} - assert_bash_exec {BASH_COMPLETION=$(cd "$SRCDIR/.."; pwd)/bash_completion} - assert_bash_exec {source "$BASH_COMPLETION"} + assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$(cd "$SRCDIR/.."; pwd)/completions} + assert_bash_exec {source $(cd "$SRCDIR/.."; pwd)/bash_completion} } @@ -980,29 +972,17 @@ proc start_bash {} { set env(SRCDIRABS) $::srcdirabs exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc" - # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS - # whenever a shopt setting is sourced or eval'ed. Disabling 'history' - # makes it not show in tests "Environment should not be modified" - # for bash < 3.2.41. - # -- FVu, Tue Sep 15 22:52:00 CEST 2009 - assert_bash_exec {is_bash_version_minimal 3 2 41 || set +o history} } # Redirect xtrace output to a file. # # 'set -x' can be very useful for debugging but by default it writes to -# stderr. Bash 4.1 has a feature to redirect this output to a random FD. +# stderr. # # This function uses file descriptor 6. This will break if any completion # tries to use the same descriptor. proc init_bash_xtrace {{fname xtrace.log}} { - global BASH_VERSINFO - if {([lindex $BASH_VERSINFO 0] == 4 && [lindex $BASH_VERSINFO 1] < 1) || - [lindex $BASH_VERSINFO 0] < 4} { - note "BASH_XTRACEFD not available in this version; no xtrace.log" - return - } verbose "Enabling bash xtrace output to '$fname'" assert_bash_exec "exec 6>'$fname'" assert_bash_exec "BASH_XTRACEFD=6" diff --git a/test/lib/library.sh b/test/lib/library.sh index 98107dcb..290ec813 100644 --- a/test/lib/library.sh +++ b/test/lib/library.sh @@ -4,9 +4,7 @@ # @param $1 Char to add to $COMP_WORDBREAKS # @see remove_comp_wordbreak_char() add_comp_wordbreak_char() { - if [ ${BASH_VERSINFO[0]} -ge 4 ]; then - [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS=$COMP_WORDBREAKS$1 - fi + [[ "${COMP_WORDBREAKS//[^$1]}" ]] || COMP_WORDBREAKS+=$1 } # add_comp_wordbreak_char() @@ -24,6 +22,8 @@ diff_env() { /[<>] _=/d # Remove PPID bash variable /[<>] PPID=/d +# Remove BASH_REMATCH bash variable + /[<>] BASH_REMATCH=/d $3" } # diff_env() @@ -60,9 +60,7 @@ is_bash_version_minimal() { # @param $1 Char to remove from $COMP_WORDBREAKS # @see add_comp_wordbreak_char() remove_comp_wordbreak_char() { - if [ ${BASH_VERSINFO[0]} -ge 4 ]; then - COMP_WORDBREAKS=${COMP_WORDBREAKS//$1} - fi + COMP_WORDBREAKS=${COMP_WORDBREAKS//$1} } # remove_comp_wordbreak_char() |
