diff options
Diffstat (limited to 'tests/test/script')
-rw-r--r-- | tests/test/script/builtin/sleep.testscript | 2 | ||||
-rw-r--r-- | tests/test/script/runner/for.testscript | 464 | ||||
-rw-r--r-- | tests/test/script/runner/pipe.testscript | 14 | ||||
-rw-r--r-- | tests/test/script/runner/set.testscript | 225 | ||||
-rw-r--r-- | tests/test/script/runner/status.testscript | 8 | ||||
-rw-r--r-- | tests/test/script/runner/timeout.testscript | 32 |
6 files changed, 711 insertions, 34 deletions
diff --git a/tests/test/script/builtin/sleep.testscript b/tests/test/script/builtin/sleep.testscript index e1410ac..c044027 100644 --- a/tests/test/script/builtin/sleep.testscript +++ b/tests/test/script/builtin/sleep.testscript @@ -13,7 +13,7 @@ $c <'sleep 1' && $b : failure : $c <'env -t 1 -- sleep 86400' && $b 2>>~%EOE% != 0 - %testscript:.*: error: sleep terminated: execution timeout expired% + %testscript:.*: error: builtin sleep terminated: execution timeout expired% %. EOE diff --git a/tests/test/script/runner/for.testscript b/tests/test/script/runner/for.testscript index 21042e5..f43fcc2 100644 --- a/tests/test/script/runner/for.testscript +++ b/tests/test/script/runner/for.testscript @@ -33,10 +33,470 @@ : special-var : $c <<EOI && $b 2>>EOE != 0 - for *: -a -b + for ~: -a -b + echo $~ >| + end + EOI + testscript:1:5: error: attempt to set '~' variable directly + EOE + + : exit + : + $c <<EOI && $b >>EOO + for x: a b + echo "$x" >| + exit + end + EOI + a + EOO + + : error + : + $c <<EOI && $b >>EOO 2>>EOE != 0 + for x: a b + echo "$x" >| + exit 'fed up' + end + EOI + a + EOO + testscript:3:3: error: fed up + info: test id: 1 + EOE +} + +: form-2 +: +: ... | for x +: +{ + : whitespace-split + : + $c <<EOI && $b >>EOO + echo " a b " | for -w x + echo "'$x'" >| + end + EOI + 'a' + 'b' + EOO + + : newline-split + : + $c <<EOI && $b >>EOO + cat <<EOF | for -n x + + + a + + + b + + EOF + echo "'$x'" >| + end + EOI + '' + '' + 'a' + '' + '' + 'b' + '' + EOO + + : typed + : + $c <<EOI && $b >>/EOO + echo "a b" | for -w x [dir_path] + echo $x >| + end + EOI + a/ + b/ + EOO + + : nested + : + $c <<EOI && $b >>EOO + echo "a b" | for -w x + echo "x y" | for -w y + echo "'$x $y'" >| + end + end + EOI + 'a x' + 'a y' + 'b x' + 'b y' + EOO + + : nested-diag + : + $c <<EOI && $b 2>>/~%EOE% != 0 + echo "a b" | for -w x + echo "x y" | for -w y + echo "'$x $y'" >"'a x'" + end + end + EOI + testscript:3:5: error: echo stdout doesn't match expected + info: stdout: test/1/stdout-i1-i2-n3 + info: expected stdout: test/1/stdout-i1-i2-n3.orig + info: stdout diff: test/1/stdout-i1-i2-n3.diff + %.+ + EOE + + : nested-diag-test-id + : + $c <<EOI && $b 2>>EOE != 0 + echo "a b" | for -w x + echo "x y" | for -w y + test -f $x$y + end + end + EOI + testscript:3:5: error: builtin test exited with code 1 + info: test id: 1 + EOE + + : var-value + : + $c <<EOI && $b >>EOO + x = 'x'; + echo "a b" | for -w x + end; + echo $x >| + EOI + b + EOO + + : both-sep-options + : + $c <<EOI && $b 2>>/~%EOE% != 0 + echo "a b" | for -n -w x + echo $x >| + end + EOI + testscript:1:1: error: for: both -n|--newline and -w|--whitespace specified + %.+ + EOE + + : invalid-option + : + $c <<EOI && $b 2>>/~%EOE% != 0 + echo "a b" | for -a x + echo $x >| + end + EOI + testscript:1:1: error: for: unknown option '-a' + %.+ + EOE + + : no-variable + : + $c <<EOI && $b 2>>/~%EOE% != 0 + echo "a b" | for -w + echo $x >| + end + EOI + testscript:1:1: error: for: missing variable name + %.+ + EOE + + : special-var + : + $c <<EOI && $b 2>>EOE != 0 + echo "a b" | for -w ~ echo $* >| end EOI - testscript:1:5: error: attempt to set '*' variable directly + testscript:1:1: error: attempt to set '~' variable directly + info: test id: 1 + EOE + + : unsep-attrs + : + $c <<EOI && $b 2>>EOE != 0 + echo "a b" | for -w x[string] + echo $x >| + end + EOI + testscript:1:1: error: for: expected variable name instead of x[string] + info: test id: 1 + EOE + + : misuse + : + { + : after-var + : + $c <<EOI && $b 2>>EOE != 0 + echo "a b" | for v: + echo $v >| + end + EOI + testscript:1:19: error: expected newline instead of ':' + EOE + + : after-attrs + : + $c <<EOI && $b 2>>EOE != 0 + echo "a b" | for v [string]: + echo $v >| + end + EOI + testscript:1:28: error: expected newline instead of ':' + EOE + } + + : exit + : + $c <<EOI && $b >>EOO + echo "a b" | for x + echo "$x" >| + exit + end + EOI + a + EOO + + : error + : + $c <<EOI && $b >>EOO 2>>EOE != 0 + echo "a b" | for x + echo "$x" >| + exit 'fed up' + end + EOI + a + EOO + testscript:3:3: error: fed up + info: test id: 1 + EOE +} + +: form-3 +: +: for x <... +: +{ + : whitespace-split + : + $c <<EOI && $b >>EOO + for -w x <" a b " + echo "'$x'" >| + end + EOI + 'a' + 'b' + EOO + + : quoted-opt + : + $c <<EOI && $b >>EOO + o = -n + for "$o" x <<EOF + a + b + EOF + echo "'$x'" >| + end; + for "($o)" x <<EOF + c + d + EOF + echo "'$x'" >| + end + EOI + 'a' + 'b' + 'c' + 'd' + EOO + + : newline-split + : + $c <<EOI && $b >>EOO + for -n x <<EOF + + + a + + + b + + EOF + echo "'$x'" >| + end + EOI + '' + '' + 'a' + '' + '' + 'b' + '' + EOO + + : string-before-var + : + $c <<EOI && $b >>EOO + for <"a b" -w x + echo "'$x'" >| + end + EOI + 'a' + 'b' + EOO + + : here-doc-before-var + : + $c <<EOI && $b >>EOO + for <<EOF -n x + a + b + EOF + echo "'$x'" >| + end + EOI + 'a' + 'b' + EOO + + : typed + : + $c <<EOI && $b >>/EOO + for -w x [dir_path] <"a b" + echo $x >| + end + EOI + a/ + b/ + EOO + + : typed-no-ops + : + $c <<EOI && $b >>/EOO + for x [dir_path] <"a b" + echo $x >| + end + EOI + a/ + b/ + EOO + + : nested + : + $c <<EOI && $b >>EOO + for -w x <"a b" + for -w y <"x y" + echo "'$x $y'" >| + end + end + EOI + 'a x' + 'a y' + 'b x' + 'b y' + EOO + + : nested-diag + : + $c <<EOI && $b 2>>/~%EOE% != 0 + for -w x <"a b" + for -w y <"x y" + echo "'$x $y'" >"'a x'" + end + end + EOI + testscript:3:5: error: echo stdout doesn't match expected + info: stdout: test/1/stdout-i1-i2-n3 + info: expected stdout: test/1/stdout-i1-i2-n3.orig + info: stdout diff: test/1/stdout-i1-i2-n3.diff + %.+ + EOE + + : nested-diag-test-id + : + $c <<EOI && $b 2>>EOE != 0 + for -w x <"a b" + for -w y <"x y" + test -f $x$y + end + end + EOI + testscript:3:5: error: builtin test exited with code 1 + info: test id: 1 + EOE + + : var-value + : + $c <<EOI && $b >>EOO + x = 'x'; + for -w x <"a b" + end; + echo $x >| + EOI + b + EOO + + : invalid-option + : + $c <<EOI && $b 2>>/~%EOE% != 0 + for -a x <"a b" + echo $x >| + end + EOI + testscript:1:1: error: for: unknown option '-a' + %. + EOE + + + : no-variable + : + $c <<EOI && $b 2>>/~%EOE% != 0 + for -w <"a b" + echo $x >| + end + EOI + testscript:1:1: error: for: missing variable name + %. + EOE + + : special-var + : + $c <<EOI && $b 2>>EOE != 0 + for ~ <"a b" + echo $~ >| + end + EOI + testscript:1:5: error: attempt to set '~' variable directly + EOE + + : exit + : + $c <<EOI && $b >>EOO + for x <"a b" + echo "$x" >| + exit + end + EOI + a + EOO + + : error + : + $c <<EOI && $b >>EOO 2>>EOE != 0 + for x <"a b" + echo "$x" >| + exit 'fed up' + end + EOI + a + EOO + testscript:3:3: error: fed up + info: test id: 1 EOE } diff --git a/tests/test/script/runner/pipe.testscript b/tests/test/script/runner/pipe.testscript index 92ab33e..cdd30a6 100644 --- a/tests/test/script/runner/pipe.testscript +++ b/tests/test/script/runner/pipe.testscript @@ -6,7 +6,6 @@ $c <'cat <foo | $* -i 1 >foo' && $b : builtin-to-process $c <'$* -o foo | cat >foo' && $b : process-to-builtin - : failure : : Note that while both commands for the pipe are faulty the diagnostics for @@ -15,10 +14,19 @@ $c <'$* -o foo | cat >foo' && $b : process-to-builtin { : exit-code : - $c <'$* -o foo -s 1 | $* -i 1 >foo -s 2' && $b 2>>/~%EOE% != 0 - %testscript:1:1: error: .+ exited with code 2% + : Also verify that the command line is printed. + : + $c <'$* -o foo -s 1 | $* -i 1 -s 2 >foo' && $b --verbose 1 2>>/~%EOE% != 0 + %. + %testscript:1:1: error: process .+ exited with code 1% + % info: command line: .+driver.* -o foo -s 1% + info: test id: 1 + %. + %testscript:1:1: error: process .+ exited with code 2% + % info: command line: .+driver.* -i 1 -s 2% info: stdout: test/1/stdout-c2 info: test id: 1 + %.{2} EOE : stderr diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript index b2944a3..1800a7d 100644 --- a/tests/test/script/runner/set.testscript +++ b/tests/test/script/runner/set.testscript @@ -76,7 +76,7 @@ : empty-attrs : - $c <"set '' baz" && $b 2>>EOE != 0 + $c <"set baz ''" && $b 2>>EOE != 0 testscript:1:1: error: set: empty variable attributes info: test id: 1 EOE @@ -300,7 +300,7 @@ $c <<EOI && $b 2>>~%EOE% != 0 $* -o 'foo' -l 10 | env -t 1 -- set bar EOI - %testscript:.*: error: set terminated: execution timeout expired% + %testscript:.*: error: .+driver.* terminated: execution timeout expired% %. EOE @@ -326,23 +326,218 @@ echo "$s" >=f; $* -o 'foo' -l 10 | cat f - | env -t 2 -- set bar EOI - %testscript:.*: error: set terminated: execution timeout expired% + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% + %. + %testscript:.*: error: builtin cat terminated: execution timeout expired% %. EOE : success : - : Note that the cat builtin ends up with the 'broken pipe' diagnostics or - : similar. - : $c <<EOI && $b echo "$s" >=f; timeout --success 2; - $* -o 'foo' -l 10 | cat f - 2>>~%EOE% | set bar - %cat: .+% - EOE + + # Suppress cat's 'broken pipe' diagnostics. + # + $* -o 'foo' -l 10 | cat f - 2>- | set bar EOI } + + : split + : + : Test various splitting modes as above, but now reading the stream in the + : non-blocking mode. + : + { + : whitespace-separated-list + : + { + : non-exact + : + { + : non-empty + : + $c <<EOI && $b + timeout 10; + set -w baz <' foo bar '; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"foo" "bar"' + EOI + + : empty + : + $c <<EOI && $b + timeout 10; + set -w baz <:''; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'' + EOI + + : spaces + : + $c <<EOI && $b + timeout 10; + set -w baz <' '; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'' + EOI + } + + : exact + : + { + : trailing-ws + : + $c <<EOI && $b + timeout 10; + set --exact --whitespace baz <' foo bar '; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"foo" "bar" ""' + EOI + + : no-trailing-ws + : + : Note that we need to strip the default trailing newline as well with the + : ':' modifier. + : + $c <<EOI && $b + timeout 10; + set -e -w baz <:' foo bar'; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"foo" "bar"' + EOI + + : empty + : + $c <<EOI && $b + timeout 10; + set -e -w baz <:''; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'' + EOI + + : spaces + : + $c <<EOI && $b + timeout 10; + set -e -w baz <' '; + echo $regex.apply($baz, '^(.*)$', '"\1"') >'""' + EOI + } + } + + : newline-separated-list + : + { + : non-exact + : + $c <<EOI && $b + timeout 10; + set -n baz <<EOF; + + foo + + bar + + EOF + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"" "foo" "" "bar" ""' + EOI + + : exact + : + { + : trailing-newline + : + $c <<EOI && $b + timeout 10; + set --exact --newline baz <<EOF; + + foo + + bar + + EOF + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"" "foo" "" "bar" "" ""' + EOI + + : no-trailing-newline + : + $c <<EOI && $b + timeout 10; + set --exact --newline baz <<:EOF; + + foo + + bar + EOF + echo $regex.apply($baz, '^(.*)$', '"\1"') >'"" "foo" "" "bar"' + EOI + } + } + + : string + : + { + : non-exact + : + $c <<EOI && $b + timeout 10; + set baz <<EOF; + + foo + + bar + + EOF + echo ($baz[0]) >>EOO + + foo + + bar + + EOO + EOI + + : exact + : + : Note that echo adds the trailing newline, so EOF and EOO here-documents + : differ by this newline. + : + { + : trailing-newline + : + $c <<EOI && $b + timeout 10; + set -e baz <<EOF; + + foo + + bar + EOF + echo ($baz[0]) >>EOO + + foo + + bar + + EOO + EOI + + : no-trailing-newline + : + $c <<EOI && $b + timeout 10; + set -e baz <<:EOF; + + foo + + bar + EOF + echo ($baz[0]) >>EOO + + foo + + bar + EOO + EOI + } + } + } } : attributes @@ -351,14 +546,14 @@ : dir_path : $c <<EOI && $b - set [dir_path] bar <'foo'; + set bar [dir_path] <'foo'; echo $bar >/'foo/' EOI : null : $c <<EOI && $b - set [null] foo <-; + set foo [null] <-; echo $foo >'' EOI @@ -376,7 +571,7 @@ : empty-brackets : $c <<EOI && $b 2>>EOE != 0 - set -w '[]' baz <'foo bar'; + set -w baz '[]' <'foo bar'; echo "$baz" EOI testscript:2:8: error: concatenating variable expansion contains multiple values @@ -385,7 +580,7 @@ : no-left-bracket : $c <<EOI && $b 2>>EOE != 0 - set -w x baz + set -w baz x EOI <attributes>:1:1: error: expected '[' instead of 'x' testscript:1:1: info: while parsing attributes 'x' @@ -395,7 +590,7 @@ : unknown : $c <<EOI && $b 2>>EOE != 0 - set -w [x] baz + set -w baz [x] EOI <attributes>:1:1: error: unknown value attribute x testscript:1:1: info: while parsing attributes '[x]' @@ -405,7 +600,7 @@ : junk : $c <<EOI && $b 2>>EOE != 0 - set -w '[string] x' baz + set -w baz '[string] x' EOI <attributes>:1:10: error: trailing junk after ']' testscript:1:1: info: while parsing attributes '[string] x' diff --git a/tests/test/script/runner/status.testscript b/tests/test/script/runner/status.testscript index e4586d9..461fd5c 100644 --- a/tests/test/script/runner/status.testscript +++ b/tests/test/script/runner/status.testscript @@ -15,7 +15,7 @@ b += --no-column : false : $c <'$* -s 1 == 0' && $b 2>>/~%EOE%d != 0 - %testscript:1: error: ../../../../driver(.exe)? exit code 1 != 0% + %testscript:1: error: process ../../../../driver(.exe)? exit code 1 != 0% info: test id: 1 EOE } @@ -30,7 +30,7 @@ b += --no-column : false : $c <'$* -s 1 != 1' && $b 2>>/~%EOE% != 0 - %testscript:1: error: ../../../../driver(.exe)? exit code 1 == 1% + %testscript:1: error: process ../../../../driver(.exe)? exit code 1 == 1% info: test id: 1 EOE } @@ -38,7 +38,7 @@ b += --no-column : error : $c <'$* -s 1 -e "Error"' && $b 2>>/~%EOE% != 0 -%testscript:1: error: ../../../driver(.exe)? exited with code 1% +%testscript:1: error: process ../../../driver(.exe)? exited with code 1% info: stderr: test/1/stderr Error info: test id: 1 @@ -47,7 +47,7 @@ EOE : error-check : $c <'$* -s 1 -e "Error" == 0' && $b 2>>/~%EOE% != 0 -%testscript:1: error: ../../../driver(.exe)? exit code 1 != 0% +%testscript:1: error: process ../../../driver(.exe)? exit code 1 != 0% info: stderr: test/1/stderr Error info: test id: 1 diff --git a/tests/test/script/runner/timeout.testscript b/tests/test/script/runner/timeout.testscript index 5f87d39..f9b6ec7 100644 --- a/tests/test/script/runner/timeout.testscript +++ b/tests/test/script/runner/timeout.testscript @@ -424,7 +424,9 @@ $c <<EOI && $b 2>>~%EOE% != 0 env -t 1 -- $* -l 86400 -o 'foo' | touch $~/foo/bar EOI - %testscript:.*: error: touch exited with code 1% + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% + %. + %testscript:.*: error: builtin touch exited with code 1% %.+ EOE } @@ -435,42 +437,54 @@ : prog-tm-prog : $c <'$* -l 10 | env -t 1 -- $* -i 0' && $b 2>>~%EOE% != 0 - %testscript:.*: error: .+driver.* terminated: execution timeout expired% + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% + %. + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% %. EOE : tm-prog-prog : $c <'env -t 1 -- $* -l 10 | $* -i 0' && $b 2>>~%EOE% != 0 - %testscript:.*: error: .+driver.* terminated: execution timeout expired% + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% + %. + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% %. EOE : tm-cat-prog : - $c <'env -t 1 -- cat <"test" | $* -l 10' && $b 2>>~%EOE% != 0 - %testscript:.*: error: cat terminated: execution timeout expired% + $c <'env -t 3 -- cat <"test" | $* -l 10' && $b 2>>~%EOE% != 0 + %testscript:.*: error: builtin cat terminated: execution timeout expired% + %. + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% %. EOE : cat-tm-prog : $c <'cat <"test" | env -t 1 -- $* -l 10' && $b 2>>~%EOE% != 0 - %testscript:.*: error: .+driver.* terminated: execution timeout expired% + %testscript:.*: error: builtin cat terminated: execution timeout expired% + %. + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% %. EOE : tm-prog-cat : $c <'env -t 1 -- $* -l 10 | cat >-' && $b 2>>~%EOE% != 0 - %testscript:.*: error: .+driver.* terminated: execution timeout expired% + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% + %. + %testscript:.*: error: builtin cat terminated: execution timeout expired% %. EOE : tm-echo-prog : - $c <'env -t 1 -- echo "test" | $* -l 10' && $b 2>>~%EOE% != 0 - %testscript:.*: error: echo terminated: execution timeout expired% + $c <'env -t 3 -- echo "test" | $* -l 10' && $b 2>>~%EOE% != 0 + %testscript:.*: error: builtin echo terminated: execution timeout expired% + %. + %testscript:.*: error: process .+driver.* terminated: execution timeout expired% %. EOE |