diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-06-03 16:00:04 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-06-03 16:00:04 +0200 |
commit | e5f2875bde2a64c9fec793dc11ade3e8bd0eb2d5 (patch) | |
tree | 6473929be282f7318e8edae0e282844a7626d66f | |
parent | 09420c7d10add24511ee39e66de07c8c136d7b12 (diff) | |
download | xe-e5f2875bde2a64c9fec793dc11ade3e8bd0eb2d5.tar.gz xe-e5f2875bde2a64c9fec793dc11ade3e8bd0eb2d5.tar.xz xe-e5f2875bde2a64c9fec793dc11ade3e8bd0eb2d5.zip |
tests: nicer fix
-rwxr-xr-x | tests | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/tests b/tests index ab9d615..c59f4b6 100755 --- a/tests +++ b/tests @@ -3,8 +3,7 @@ printf '1..44\n' set -e -: ${XE:=./xe} -xe() { printf 'Tried to run xe directly, use $XE.\n' 2>&1; exit 111; } +xe() { "${XE:-./xe}" "$@"; } necho() { for a; do printf '%s\n' "$a"; done; } @@ -26,38 +25,38 @@ check_output() { printf '# simple tests\n' -check_output 'single argument run' 'necho 1 2 3 | $XE echo' <<EOF +check_output 'single argument run' 'necho 1 2 3 | xe echo' <<EOF 1 2 3 EOF -check_output 'dual argument run' 'necho 1 2 3 4 5 | $XE -N2 echo' <<EOF +check_output 'dual argument run' 'necho 1 2 3 4 5 | xe -N2 echo' <<EOF 1 2 3 4 5 EOF -check_output 'unlimited argument run' 'necho 1 2 3 4 5 | $XE -N0 echo' <<EOF +check_output 'unlimited argument run' 'necho 1 2 3 4 5 | xe -N0 echo' <<EOF 1 2 3 4 5 EOF -check_output 'empty input run' 'true | $XE echo a' <<EOF +check_output 'empty input run' 'true | xe echo a' <<EOF EOF -check_output 'dry run' 'necho a b c | $XE -n echo x' <<EOF +check_output 'dry run' 'necho a b c | xe -n echo x' <<EOF echo x a echo x b echo x c EOF -check_output 'dry run quoting' 'necho a "b b" c | $XE -n echo x' <<EOF +check_output 'dry run quoting' 'necho a "b b" c | xe -n echo x' <<EOF echo x a echo x 'b b' echo x c EOF -check_output 'verbose run' 'necho a b c | $XE -v echo x' <<EOF +check_output 'verbose run' 'necho a b c | xe -v echo x' <<EOF echo x a x a echo x b @@ -66,117 +65,117 @@ echo x c x c EOF -check_output 'with no command' 'necho 1 2 3 | $XE -N2' <<EOF +check_output 'with no command' 'necho 1 2 3 | xe -N2' <<EOF 1 2 3 EOF -check_output 'using {}' 'necho 1 2 3 | $XE echo a {} x' <<EOF +check_output 'using {}' 'necho 1 2 3 | xe echo a {} x' <<EOF a 1 x a 2 x a 3 x EOF -check_output 'using {} twice' 'necho 1 2 3 | $XE echo {} x {}' <<EOF +check_output 'using {} twice' 'necho 1 2 3 | xe echo {} x {}' <<EOF 1 x {} 2 x {} 3 x {} EOF -check_output 'using -I%' 'necho 1 2 3 | $XE -I% echo {} x %' <<EOF +check_output 'using -I%' 'necho 1 2 3 | xe -I% echo {} x %' <<EOF {} x 1 {} x 2 {} x 3 EOF -check_output 'using -I "" to disable' 'necho 1 2 3 | $XE -I "" echo {} x %' <<EOF +check_output 'using -I "" to disable' 'necho 1 2 3 | xe -I "" echo {} x %' <<EOF {} x % 1 {} x % 2 {} x % 3 EOF -check_output 'using {} with multiple arguments' 'necho 1 2 3 | $XE -N2 echo a {} x {}' <<EOF +check_output 'using {} with multiple arguments' 'necho 1 2 3 | xe -N2 echo a {} x {}' <<EOF a 1 2 x {} a 3 x {} EOF -check_output 'using -0' 'printf "foo\0bar\0quux" | $XE -0 echo' <<EOF +check_output 'using -0' 'printf "foo\0bar\0quux" | xe -0 echo' <<EOF foo bar quux EOF -check_output 'using -a' '$XE -a echo -- 1 2 3' <<EOF +check_output 'using -a' 'xe -a echo -- 1 2 3' <<EOF 1 2 3 EOF -check_output 'using -a with no arguments' '$XE -a echo' <<EOF +check_output 'using -a with no arguments' 'xe -a echo' <<EOF EOF -check_output 'using -a with no command' '$XE -N2 -a -- 1 2 3' <<EOF +check_output 'using -a with no command' 'xe -N2 -a -- 1 2 3' <<EOF 1 2 3 EOF -check_output 'using -A%' '$XE -A% echo -- % 1 2 3' <<EOF +check_output 'using -A%' 'xe -A% echo -- % 1 2 3' <<EOF -- 1 -- 2 -- 3 EOF -check_output 'using -A% with no arguments' '$XE -A% echo || true' <<EOF +check_output 'using -A% with no arguments' 'xe -A% echo || true' <<EOF xe: '-A %' used but no separator '%' found in command line. EOF -check_output 'using -A% with no command' '$XE -N2 -A% % 1 2 3' <<EOF +check_output 'using -A% with no command' 'xe -N2 -A% % 1 2 3' <<EOF 1 2 3 EOF -check_output 'using -f' 'necho notme | $XE -f tests echo | grep ^notme || echo success' <<EOF +check_output 'using -f' 'necho notme | xe -f tests echo | grep ^notme || echo success' <<EOF success EOF -check_output 'using -s' 'necho 1 2 3 | $XE -s "echo x\$1"' <<EOF +check_output 'using -s' 'necho 1 2 3 | xe -s "echo x\$1"' <<EOF x1 x2 x3 EOF -check_output 'using -s with -N0' 'necho 1 2 3 | $XE -N0 -s "echo x\$@"' <<EOF +check_output 'using -s with -N0' 'necho 1 2 3 | xe -N0 -s "echo x\$@"' <<EOF x1 2 3 EOF -check_output 'using -s with -a' '$XE -s "echo x\$@" -a 1 2 3' <<EOF +check_output 'using -s with -a' 'xe -s "echo x\$@" -a 1 2 3' <<EOF x1 x2 x3 EOF -check_output 'using -s with -a' '$XE -a -s "echo x\$@" 1 2 3' <<EOF +check_output 'using -s with -a' 'xe -a -s "echo x\$@" 1 2 3' <<EOF x1 x2 x3 EOF -check_output 'using -s with -a' '$XE -a -s "echo x\$@" -- 1 2 3' <<EOF +check_output 'using -s with -a' 'xe -a -s "echo x\$@" -- 1 2 3' <<EOF x1 x2 x3 EOF -check_output 'with ITER' '$XE -a -s "echo \$ITER" -- a b c' <<EOF +check_output 'with ITER' 'xe -a -s "echo \$ITER" -- a b c' <<EOF 1 2 3 EOF -check_output 'is eager' '{ echo 1; sleep 1; echo 11 >/dev/stderr; echo 2; } | $XE echo' <<EOF +check_output 'is eager' '{ echo 1; sleep 1; echo 11 >/dev/stderr; echo 2; } | xe echo' <<EOF 1 11 2 @@ -184,59 +183,59 @@ EOF printf '# error handling\n' -check_output 'exit code on success' 'true | $XE; echo $?' <<EOF +check_output 'exit code on success' 'true | xe; echo $?' <<EOF 0 EOF -check_output 'exit code on other error' 'true | $XE -j NaN 2>/dev/null || echo $?' <<EOF +check_output 'exit code on other error' 'true | xe -j NaN 2>/dev/null || echo $?' <<EOF 1 EOF -check_output 'exit code on when command fails with 1-125' 'necho a | $XE -s "exit 42" || echo $?' <<EOF +check_output 'exit code on when command fails with 1-125' 'necho a | xe -s "exit 42" || echo $?' <<EOF 123 EOF -check_output 'exit code on when command fails with 255' 'necho a | $XE -s "exit 255" 2>/dev/null || echo $?' <<EOF +check_output 'exit code on when command fails with 255' 'necho a | xe -s "exit 255" 2>/dev/null || echo $?' <<EOF 124 EOF -check_output 'exit code when process was killed' 'necho a | $XE -s "kill -HUP \$\$" 2>/dev/null || echo $?' <<EOF +check_output 'exit code when process was killed' 'necho a | xe -s "kill -HUP \$\$" 2>/dev/null || echo $?' <<EOF 125 EOF -check_output 'exit code when command cannot be run' 'necho a | $XE /dev/null/calc.exe 2>/dev/null || echo $?' <<EOF +check_output 'exit code when command cannot be run' 'necho a | xe /dev/null/calc.exe 2>/dev/null || echo $?' <<EOF 126 EOF -check_output 'exit code when command was not found' 'necho a | $XE /bin/calc.exe 2>/dev/null || echo $?' <<EOF +check_output 'exit code when command was not found' 'necho a | xe /bin/calc.exe 2>/dev/null || echo $?' <<EOF 127 EOF -check_output 'exit code on empty input when run with -R' 'true | $XE -R echo a || echo $?' <<EOF +check_output 'exit code on empty input when run with -R' 'true | xe -R echo a || echo $?' <<EOF 122 EOF -check_output 'doesn'\''t stop on errors by default' 'necho a b c | $XE -s "if [ b = \$1 ]; then false; else echo \$1; fi" || echo $?' <<EOF +check_output 'doesn'\''t stop on errors by default' 'necho a b c | xe -s "if [ b = \$1 ]; then false; else echo \$1; fi" || echo $?' <<EOF a c 123 EOF -check_output 'stops on first error with -F' 'necho a b c | $XE -F -s "if [ b = \$1 ]; then false; else echo \$1; fi" 2>/dev/null || echo $?' <<EOF +check_output 'stops on first error with -F' 'necho a b c | xe -F -s "if [ b = \$1 ]; then false; else echo \$1; fi" 2>/dev/null || echo $?' <<EOF a 123 EOF -check_output 'should close stdin when arguments were read from it' 'necho a b c | $XE -s "sed q"' <<EOF +check_output 'should close stdin when arguments were read from it' 'necho a b c | xe -s "sed q"' <<EOF EOF -check_output 'should not close stdin when arguments were read from command line' 'yes | $XE -a -s "sed q" -- 1 2 3' <<EOF +check_output 'should not close stdin when arguments were read from command line' 'yes | xe -a -s "sed q" -- 1 2 3' <<EOF y y y EOF -check_output 'should not close stdin when arguments were read from file' 'yes | $XE -f tests -s "sed q" | sed 3q' <<EOF +check_output 'should not close stdin when arguments were read from file' 'yes | xe -f tests -s "sed q" | sed 3q' <<EOF y y y @@ -244,20 +243,20 @@ EOF printf '# regressions\n' -check_output '0fb64a4 quoting of empty strings' 'printf "foo\n\n" | $XE -N2 -v true' <<EOF +check_output '0fb64a4 quoting of empty strings' 'printf "foo\n\n" | xe -N2 -v true' <<EOF true foo '' EOF printf '# limit checks, expecting maximal POSIX limits available\n' -check_output 'argscap check' 'head -c 17711 /dev/zero | tr "\0" "\012" | $XE -N0 -s "echo \$#"' <<EOF +check_output 'argscap check' 'head -c 17711 /dev/zero | tr "\0" "\012" | xe -N0 -s "echo \$#"' <<EOF 8187 8187 1337 EOF bloat() { perl -e 'print "x"x8000, "\n" for 1..42'; } -check_output 'argslen check' 'bloat | $XE -N0 -s "echo \$#"' <<EOF +check_output 'argslen check' 'bloat | xe -N0 -s "echo \$#"' <<EOF 16 16 10 |