diff options
author | David Paleino <dapal@debian.org> | 2012-01-07 23:44:41 +0100 |
---|---|---|
committer | David Paleino <dapal@debian.org> | 2012-01-07 23:44:41 +0100 |
commit | a4fa390b28abb15d43a1418ae0585dc636057b84 (patch) | |
tree | a623d66e960a7d534d85c4c8d960d8c6ce93f76d /test | |
parent | 935ce88df7f6bfef86e44c732228f8575ca3cd67 (diff) | |
parent | 3ccfe020a2b7e1e3a97e725c2af001275a07d15c (diff) | |
download | bash-completion-a4fa390b28abb15d43a1418ae0585dc636057b84.tar.gz |
Merge commit '3ccfe02' into 2.x
Diffstat (limited to 'test')
53 files changed, 571 insertions, 23 deletions
diff --git a/test/completion/ccache.exp b/test/completion/ccache.exp new file mode 100644 index 00000000..4d88bf98 --- /dev/null +++ b/test/completion/ccache.exp @@ -0,0 +1 @@ +assert_source_completions ccache diff --git a/test/completion/desktop-file-validate.exp b/test/completion/desktop-file-validate.exp new file mode 100644 index 00000000..e026a68c --- /dev/null +++ b/test/completion/desktop-file-validate.exp @@ -0,0 +1 @@ +assert_source_completions desktop-file-validate diff --git a/test/completion/export.exp b/test/completion/export.exp new file mode 100644 index 00000000..bab517a9 --- /dev/null +++ b/test/completion/export.exp @@ -0,0 +1 @@ +assert_source_completions export diff --git a/test/completion/htop.exp b/test/completion/htop.exp new file mode 100644 index 00000000..c5372475 --- /dev/null +++ b/test/completion/htop.exp @@ -0,0 +1 @@ +assert_source_completions htop diff --git a/test/completion/iperf.exp b/test/completion/iperf.exp new file mode 100644 index 00000000..f5f19ef5 --- /dev/null +++ b/test/completion/iperf.exp @@ -0,0 +1 @@ +assert_source_completions iperf diff --git a/test/completion/koji.exp b/test/completion/koji.exp new file mode 100644 index 00000000..4d85dfc2 --- /dev/null +++ b/test/completion/koji.exp @@ -0,0 +1 @@ +assert_source_completions koji diff --git a/test/completion/lzip.exp b/test/completion/lzip.exp new file mode 100644 index 00000000..faa83a41 --- /dev/null +++ b/test/completion/lzip.exp @@ -0,0 +1 @@ +assert_source_completions lzip diff --git a/test/completion/nethogs.exp b/test/completion/nethogs.exp new file mode 100644 index 00000000..4d501ace --- /dev/null +++ b/test/completion/nethogs.exp @@ -0,0 +1 @@ +assert_source_completions nethogs diff --git a/test/completion/pidof.exp b/test/completion/pidof.exp new file mode 100644 index 00000000..c66ee9f9 --- /dev/null +++ b/test/completion/pidof.exp @@ -0,0 +1 @@ +assert_source_completions pidof diff --git a/test/completion/plague-client.exp b/test/completion/plague-client.exp new file mode 100644 index 00000000..6f9a9373 --- /dev/null +++ b/test/completion/plague-client.exp @@ -0,0 +1 @@ +assert_source_completions plague-client diff --git a/test/completion/udevadm.exp b/test/completion/udevadm.exp new file mode 100644 index 00000000..69c980ff --- /dev/null +++ b/test/completion/udevadm.exp @@ -0,0 +1 @@ +assert_source_completions udevadm diff --git a/test/completion/umount.exp b/test/completion/umount.exp new file mode 100644 index 00000000..39c4d114 --- /dev/null +++ b/test/completion/umount.exp @@ -0,0 +1 @@ +assert_source_completions umount diff --git a/test/completion/valgrind.exp b/test/completion/valgrind.exp new file mode 100644 index 00000000..aadd5a52 --- /dev/null +++ b/test/completion/valgrind.exp @@ -0,0 +1 @@ +assert_source_completions valgrind diff --git a/test/completion/vi.exp b/test/completion/vi.exp new file mode 100644 index 00000000..b0191404 --- /dev/null +++ b/test/completion/vi.exp @@ -0,0 +1 @@ +assert_source_completions vi diff --git a/test/completion/wine.exp b/test/completion/wine.exp new file mode 100644 index 00000000..ddb1e6f1 --- /dev/null +++ b/test/completion/wine.exp @@ -0,0 +1 @@ +assert_source_completions wine diff --git a/test/fixtures/_known_hosts_real/config_tilde b/test/fixtures/_known_hosts_real/config_tilde index 1068e299..0893515b 100644 --- a/test/fixtures/_known_hosts_real/config_tilde +++ b/test/fixtures/_known_hosts_real/config_tilde @@ -1,4 +1,4 @@ # With quotes and tilde UserKnownHostsFile "~/fixtures/_known_hosts_real/known_hosts2" -# Without quotes, with tilde -UserKnownHostsFile ~/fixtures/_known_hosts_real/known_hosts3 +# Without quotes, with tilde, and another on the same line +UserKnownHostsFile ~/fixtures/_known_hosts_real/known_hosts3 fixtures/_known_hosts_real/known_hosts4 diff --git a/test/fixtures/_known_hosts_real/known_hosts b/test/fixtures/_known_hosts_real/known_hosts index f655eaa3..0d6f5025 100644 --- a/test/fixtures/_known_hosts_real/known_hosts +++ b/test/fixtures/_known_hosts_real/known_hosts @@ -3,7 +3,7 @@ doo ike ssh-rsa qwerty1234/Qwerty+1234== jub,10.0.0.1 -kyl,100.0.0.2 +@cert-authority kyl,100.0.0.2 xxxfoo [10.10.0.3]:10022 [blah]:1234 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 diff --git a/test/fixtures/_known_hosts_real/known_hosts2 b/test/fixtures/_known_hosts_real/known_hosts2 index f719efd4..2eb4d4f7 100644 --- a/test/fixtures/_known_hosts_real/known_hosts2 +++ b/test/fixtures/_known_hosts_real/known_hosts2 @@ -1 +1 @@ -two +two,two2,two3,two*,t?o,two4 diff --git a/test/fixtures/_known_hosts_real/known_hosts4 b/test/fixtures/_known_hosts_real/known_hosts4 new file mode 100644 index 00000000..85106651 --- /dev/null +++ b/test/fixtures/_known_hosts_real/known_hosts4 @@ -0,0 +1 @@ +four diff --git a/test/fixtures/make/Makefile b/test/fixtures/make/Makefile new file mode 100644 index 00000000..1a6416cd --- /dev/null +++ b/test/fixtures/make/Makefile @@ -0,0 +1,16 @@ +NAME := sample + +.PHONY: all +all: $(NAME) + +$(NAME): sample.c + cc -o $@ $^ + +.PHONY: install +install: all + mkdir -p /usr/bin + install -m 755 $(NAME) /usr/bin + +.PHONY: clean +clean: + -rm -f $(NAME) diff --git a/test/fixtures/make/empty_dir/.nothing_here b/test/fixtures/make/empty_dir/.nothing_here new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/make/empty_dir/.nothing_here diff --git a/test/fixtures/make/sample.c b/test/fixtures/make/sample.c new file mode 100644 index 00000000..2be4600f --- /dev/null +++ b/test/fixtures/make/sample.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(void) +{ + puts("Hello, world!"); + return 0; +} diff --git a/test/fixtures/shared/ld.so.conf.d/foo.txt b/test/fixtures/shared/ld.so.conf.d/foo.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/shared/ld.so.conf.d/foo.txt diff --git a/test/fixtures/shared/ld.so.conf.d/libfoo.conf b/test/fixtures/shared/ld.so.conf.d/libfoo.conf new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/shared/ld.so.conf.d/libfoo.conf diff --git a/test/fixtures/shared/ld.so.conf.d/libfoo.so b/test/fixtures/shared/ld.so.conf.d/libfoo.so new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/shared/ld.so.conf.d/libfoo.so diff --git a/test/fixtures/shared/ld.so.conf.d/libfoo.so.1 b/test/fixtures/shared/ld.so.conf.d/libfoo.so.1 new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/fixtures/shared/ld.so.conf.d/libfoo.so.1 diff --git a/test/lib/completions/ccache.exp b/test/lib/completions/ccache.exp new file mode 100644 index 00000000..156c881a --- /dev/null +++ b/test/lib/completions/ccache.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "ccache -" +sync_after_int + + +teardown diff --git a/test/lib/completions/cppcheck.exp b/test/lib/completions/cppcheck.exp index 4acd709a..80b6e7b6 100644 --- a/test/lib/completions/cppcheck.exp +++ b/test/lib/completions/cppcheck.exp @@ -27,4 +27,16 @@ assert_no_complete "cppcheck -D " sync_after_int +assert_complete "--enable=all" "cppcheck --enable=al" +sync_after_int + + +assert_complete "--enable=xx,style" "cppcheck --enable=xx,styl" +sync_after_int + + +assert_complete "--enable=xx,yy,style" "cppcheck --enable=xx,yy,styl" +sync_after_int + + teardown diff --git a/test/lib/completions/desktop-file-validate.exp b/test/lib/completions/desktop-file-validate.exp new file mode 100644 index 00000000..40cbf82f --- /dev/null +++ b/test/lib/completions/desktop-file-validate.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "desktop-file-validate " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/export.exp b/test/lib/completions/export.exp new file mode 100644 index 00000000..84cb9170 --- /dev/null +++ b/test/lib/completions/export.exp @@ -0,0 +1,55 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified { + /OLDPWD=/d + } +} + + +setup + + +assert_complete_any "export BASH" +sync_after_int + + +assert_complete_any "export -n BASH" +sync_after_int + + +assert_no_complete "export -p " +sync_after_int + + +assert_complete_dir {bar "bar bar.d/" foo foo.d/} "export FOO=" \ + fixtures/shared/default +sync_after_int + + +assert_complete_dir {foo foo.d/} "export FOO=f" fixtures/shared/default "" \ + -expect-cmd-minus f +sync_after_int + + +# Functions: _export, _expand, ... +assert_complete_any "export -fn _ex" +sync_after_int + + +assert_complete_any "export -f -n _ex" +sync_after_int + + +assert_complete_any "export FOO=\$BASH" +sync_after_int + + +assert_complete_any "export -" +sync_after_int + + +teardown diff --git a/test/lib/completions/htop.exp b/test/lib/completions/htop.exp new file mode 100644 index 00000000..d3e94d10 --- /dev/null +++ b/test/lib/completions/htop.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "htop -" + + +sync_after_int + + +teardown diff --git a/test/lib/completions/iperf.exp b/test/lib/completions/iperf.exp new file mode 100644 index 00000000..66a0ba3b --- /dev/null +++ b/test/lib/completions/iperf.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "iperf " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/killall.exp b/test/lib/completions/killall.exp index 1ee3ade8..feec9337 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 --signal " sync_after_int diff --git a/test/lib/completions/koji.exp b/test/lib/completions/koji.exp new file mode 100644 index 00000000..a9673807 --- /dev/null +++ b/test/lib/completions/koji.exp @@ -0,0 +1,22 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "koji " +sync_after_int + + +assert_complete_any "koji -" +sync_after_int + + +teardown diff --git a/test/lib/completions/lzip.exp b/test/lib/completions/lzip.exp new file mode 100644 index 00000000..fd92af62 --- /dev/null +++ b/test/lib/completions/lzip.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "lzip " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/make.exp b/test/lib/completions/make.exp index 64a393da..977485d2 100644 --- a/test/lib/completions/make.exp +++ b/test/lib/completions/make.exp @@ -4,14 +4,39 @@ proc setup {} { proc teardown {} { - assert_env_unmodified + assert_env_unmodified {/OLDPWD=/d} } setup -assert_complete_any "make " +set test "-f Ma<TAB> should complete \"Makefile\"" +set dir $::srcdir/fixtures/make +assert_complete_dir "Makefile" "make -f Ma" $dir $test + + +sync_after_int + + +set test "\"make <TAB>\" should complete targets" +set dir $::srcdir/fixtures/make +set targets "all sample install clean" +assert_complete_dir $targets "make " $dir $test + + +sync_after_int + + +set test "\"make <TAB>\" should not show anything in directory without makefile" +set dir $::srcdir/fixtures/make/empty_dir +assert_complete_dir "" "make " $dir $test + + +sync_after_int + + +assert_complete_any "make -j " sync_after_int diff --git a/test/lib/completions/nethogs.exp b/test/lib/completions/nethogs.exp new file mode 100644 index 00000000..d6234070 --- /dev/null +++ b/test/lib/completions/nethogs.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "nethogs " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp index 9a9d9fbf..a745b55d 100644 --- a/test/lib/completions/perldoc.exp +++ b/test/lib/completions/perldoc.exp @@ -24,17 +24,10 @@ expect { -re /@ { unresolved "$test" } default { unresolved "$test" } } - - sync_after_int -set test "- should complete options" -set options { - -h -v -t -u -m -l -F -X -f -q -} -assert_complete $options "perldoc -" $test - +assert_complete_any "perldoc -" sync_after_int diff --git a/test/lib/completions/pidof.exp b/test/lib/completions/pidof.exp new file mode 100644 index 00000000..8fdab978 --- /dev/null +++ b/test/lib/completions/pidof.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "pidof " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/plague-client.exp b/test/lib/completions/plague-client.exp new file mode 100644 index 00000000..ddcc8491 --- /dev/null +++ b/test/lib/completions/plague-client.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "plague-client " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp index 1599dccc..3ef0bb69 100644 --- a/test/lib/completions/ssh.exp +++ b/test/lib/completions/ssh.exp @@ -60,7 +60,7 @@ sync_after_int set test "First argument should complete partial hostname" -assert_complete_partial [get_hosts] ssh "" $test -ltrim-colon-completions +assert_complete_partial [get_known_hosts] ssh "l" $test -ltrim-colon-completions sync_after_int diff --git a/test/lib/completions/udevadm.exp b/test/lib/completions/udevadm.exp new file mode 100644 index 00000000..bef16f0b --- /dev/null +++ b/test/lib/completions/udevadm.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "udevadm " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/umount.exp b/test/lib/completions/umount.exp new file mode 100644 index 00000000..21a2dfa5 --- /dev/null +++ b/test/lib/completions/umount.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "umount " + + +sync_after_int + + +teardown diff --git a/test/lib/completions/upgradepkg.exp b/test/lib/completions/upgradepkg.exp index 860dde9e..4783aec3 100644 --- a/test/lib/completions/upgradepkg.exp +++ b/test/lib/completions/upgradepkg.exp @@ -36,4 +36,16 @@ assert_complete_dir $files "upgradepkg " $dir $test sync_after_int +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/valgrind.exp b/test/lib/completions/valgrind.exp new file mode 100644 index 00000000..6e3702b6 --- /dev/null +++ b/test/lib/completions/valgrind.exp @@ -0,0 +1,50 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +# b: assuming we have at least bash that starts with b in $PATH +assert_complete_any "valgrind b" + + +sync_after_int + + +assert_complete_any "valgrind -" + + +sync_after_int + + +set test "--tool=memche<TAB> should complete \"memcheck\"" +assert_complete "--tool=memcheck" "valgrind --tool=memche" $test + + +sync_after_int + + +set test "--tool=helgrind --history-l<TAB> should complete \"--history-level=\"" +assert_complete "--history-level=" "valgrind --tool=helgrind --history-l" $test -nospace + + +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 "valgrind --log-file=v\\ 0.log ./bin/" $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/completions/vi.exp b/test/lib/completions/vi.exp new file mode 100644 index 00000000..db3e3deb --- /dev/null +++ b/test/lib/completions/vi.exp @@ -0,0 +1,22 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "vi " +sync_after_int + + +assert_complete {libfoo.conf foo.txt} "vi $::srcdir/fixtures/shared/ld.so.conf.d/" +sync_after_int + + +teardown diff --git a/test/lib/completions/wine.exp b/test/lib/completions/wine.exp new file mode 100644 index 00000000..2cc60c48 --- /dev/null +++ b/test/lib/completions/wine.exp @@ -0,0 +1,31 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified {/OLDPWD=/d} +} + + +setup + + +set test "should complete *.exe, *.com files and dirs" +set dir $::srcdir/fixtures/shared/default +assert_complete_dir {"bar bar.d/" foo.d/} "wine " $dir $test + + +sync_after_int + + +set test "should complete any files and dirs after executable" +set dir $::srcdir/fixtures/shared/default +set files {bar "bar bar.d/" foo foo.d/} +assert_complete_dir $files "wine notepad " $dir $test + + +sync_after_int + + +teardown diff --git a/test/lib/library.exp b/test/lib/library.exp index f6e9f21a..b2233258 100644 --- a/test/lib/library.exp +++ b/test/lib/library.exp @@ -357,8 +357,9 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} { } -# Make sure the expected files are returned by TAB-completing the -# specified command in the specified subdirectory. +# Make sure the expected files are returned by TAB-completing the specified +# command in the specified subdirectory. Be prepared to filter out OLDPWD +# changes when calling assert_env_unmodified() after using this procedure. # @param list $expected # @param string $cmd Command given to generate items # @param string $dir Subdirectory to attempt completion in. The directory must be relative from the $TESTDIR and without a trailing slash. E.g. `fixtures/evince' @@ -368,7 +369,7 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} { proc assert_complete_dir {expected cmd dir {test ""} {args {}}} { set prompt "/@" assert_bash_exec "cd $dir" "" $prompt - assert_complete $expected $cmd $test $args + eval assert_complete \$expected \$cmd \$test $args sync_after_int $prompt assert_bash_exec {cd "$TESTDIR"} } diff --git a/test/unit/_get_comp_words_by_ref.exp b/test/unit/_get_comp_words_by_ref.exp index f5c7ab38..c113f6df 100644 --- a/test/unit/_get_comp_words_by_ref.exp +++ b/test/unit/_get_comp_words_by_ref.exp @@ -115,6 +115,14 @@ assert_bash_list {"b\\ c a"} $cmd $test sync_after_int +set test {a\ b a\ b| should return a\ b}; # | = cursor position +set cmd {COMP_WORDS=('a\ b' 'a\ b'); COMP_CWORD=1; COMP_LINE='a\ b a\ b'; COMP_POINT=9; _get_comp_words_by_ref cur prev; echo "$cur $prev"} +assert_bash_list {"a\\ b a\\ b"} $cmd $test + + +sync_after_int + + set test {a b\| c should return b\ }; # | = cursor position set cmd {COMP_WORDS=(a 'b\ c'); COMP_CWORD=1; COMP_LINE='a b\ c'; COMP_POINT=4; _get_comp_words_by_ref cur prev; echo "$cur $prev"} assert_bash_list {"b\\ a"} $cmd $test diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp index 0e381fa7..30ede41c 100644 --- a/test/unit/_known_hosts_real.exp +++ b/test/unit/_known_hosts_real.exp @@ -52,8 +52,8 @@ set test "Files containing consecutive spaces should work" set hosts [get_hosts -unsorted] set hosts_orig $hosts # Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced conf' - # Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2 -lappend hosts gee hus two + # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 +lappend hosts gee hus two two2 two3 two4 set hosts_config $hosts # Hosts `doo' and `ike' are defined in `./fixtures/_known_hosts_/spaced known_hosts' lappend hosts doo ike @@ -78,9 +78,10 @@ sync_after_int set test "Files starting with tilde (~) should work" set hosts [get_hosts -unsorted] - # Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2 + # Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2 # Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3 -lappend hosts two three + # Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4 +lappend hosts two two2 two3 two4 three four set hosts [join [bash_sort $hosts] "\\s+"] # Setup environment set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS} diff --git a/test/unit/_parse_help.exp b/test/unit/_parse_help.exp index a6d58d5a..43c5dc29 100644 --- a/test/unit/_parse_help.exp +++ b/test/unit/_parse_help.exp @@ -7,6 +7,7 @@ proc setup {} { proc teardown {} { assert_env_unmodified { /declare -f fn/d + /PIPESTATUS=/d } } @@ -129,5 +130,9 @@ set cmd {fn() { printf '%s\n' "-f or --foo"; }; _parse_help fn} assert_bash_list "--foo" $cmd "-f or --foo" sync_after_int +set cmd { printf '%s\n' "-f or --foo" | _parse_help - } +assert_bash_list "--foo" $cmd "from stdin" +sync_after_int + teardown diff --git a/test/unit/_parse_usage.exp b/test/unit/_parse_usage.exp index 0069848d..5a40b1fe 100644 --- a/test/unit/_parse_usage.exp +++ b/test/unit/_parse_usage.exp @@ -5,6 +5,7 @@ proc setup {} { proc teardown {} { assert_env_unmodified { /declare -f fn/d + /PIPESTATUS=/d } } @@ -55,5 +56,9 @@ set cmd {fn() { printf '%s\n' "----\n---foo\n----- bar"; }; _parse_usage fn} assert_bash_list "" $cmd "many dashes" sync_after_int +set cmd { printf '%s\n' "[-duh]" | _parse_usage - } +assert_bash_list "-d -u -h" $cmd "from stdin" +sync_after_int + teardown diff --git a/test/unit/quote.exp b/test/unit/quote.exp new file mode 100644 index 00000000..afe670a2 --- /dev/null +++ b/test/unit/quote.exp @@ -0,0 +1,69 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +set cmd {quote "a b"} +set test {quote "a b" should output 'a b'} +send "$cmd\r" +expect -ex "$cmd\r\n" +expect { + -re {'a b'} { pass $test } + default { fail $test } +} +sync_after_int + + +set cmd {quote "a b"} +set test {quote "a b" should output 'a b'} +send "$cmd\r" +expect -ex "$cmd\r\n" +expect { + -re {'a b'} { pass $test } + default { fail $test } +} +sync_after_int + + +set cmd {quote " a "} +set test {quote " a " should output ' a '} +send "$cmd\r" +expect -ex "$cmd\r\n" +expect { + -re {' a '} { pass $test } + default { fail $test } +} +sync_after_int + + +set cmd {quote "a'b'c"} +set test {quote "a'b'c" should output 'a'\''b'\''c'} +send "$cmd\r" +expect -ex "$cmd\r\n" +expect { + -re {'a'\\''b'\\''c'} { pass $test } + default { fail $test } +} +sync_after_int + + +set cmd {quote "a'"} +set test {quote "a'" should output 'a'\'''} +send "$cmd\r" +expect -ex "$cmd\r\n" +expect { + -re {'a'\\'''} { pass $test } + default { fail $test } +} +sync_after_int + + +teardown |