From 5007870b52aa549971824959a55ad3bb886f09e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Sep 2018 16:37:32 +0200 Subject: Rename .test/test{} to .testscript/testscript{} --- tests/test/script/runner/set.testscript | 278 ++++++++++++++++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 tests/test/script/runner/set.testscript (limited to 'tests/test/script/runner/set.testscript') diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript new file mode 100644 index 0000000..b10ce1e --- /dev/null +++ b/tests/test/script/runner/set.testscript @@ -0,0 +1,278 @@ +# file : tests/test/script/runner/set.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: special +: +{ + : pipelining + : + $c <'set foo | cat >bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin must be the last pipe command + EOE + + : redirecting + : + { + : stdout + : + $c <'set foo >bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin stdout cannot be redirected + EOE + + : stderr + : + $c <'set foo 2>bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin stderr cannot be redirected + EOE + } + + : status + : + $c <'set foo == 1' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin exit code cannot be non-zero + EOE +} + +: arguments +: +{ + : none + : + $c <'set -e' && $b 2>>EOE != 0 + testscript:1:1: error: missing variable name + EOE + + : unexpected + : + $c <'set foo bar baz' && $b 2>>EOE != 0 + testscript:1:1: error: unexpected argument + EOE + + : empty-attrs + : + $c <"set '' baz" && $b 2>>EOE != 0 + testscript:1:1: error: empty variable attributes + EOE + + : empty-var + : + $c <"set ''" && $b 2>>EOE != 0 + testscript:1:1: error: empty variable name + EOE +} + +: whitespace-separated-list +: +{ + : non-exact + : + $c <'foo bar' + EOI + + : exact + : + { + : trailing-ws + : + $c <'foo bar ' + EOI + + : no-trailing-ws + : + : Note that we need to strip the default trailing newline as well with the + : ':' modifier. + : + $c <'foo bar' + EOI + } +} + +: newline-separated-list +: +{ + : non-exact + : + $c <' foo bar ' + EOI + + : exact + : + { + : trailing-newline + : + $c <' foo bar ' + EOI + + : no-trailing-newline + : + $c <' foo bar' + EOI + } +} + +: string +: +{ + : non-exact + : + $c <>EOO + + foo + + bar + + EOO + EOI + + : roundtrip + : + echo 'foo' | set bar; + echo "$bar" >'foo' + + : exact + : + : Note that echo adds the trailing newline, so EOF and EOO here-documents + : differ by this newline. + : + { + : trailing-newline + : + $c <>EOO + + foo + + bar + + EOO + EOI + + : no-trailing-newline + : + $c <>EOO + + foo + + bar + EOO + EOI + } +} + +: attributes +: +{ + : dir_path + : + $c </'foo/' + EOI + + : null + : + $c <'' + EOI + + : none + : + $c <>EOE != 0 + set -w baz <'foo bar'; + echo "$baz" + EOI + testscript:2:8: error: concatenating variable expansion contains multiple values + EOE + + # @@ Move the following tests to build2 parser unit tests when created. + # + : empty-brackets + : + $c <>EOE != 0 + set -w '[]' baz <'foo bar'; + echo "$baz" + EOI + testscript:2:8: error: concatenating variable expansion contains multiple values + EOE + + : no-left-bracket + : + $c <>EOE != 0 + set -w x baz + EOI + :1:1: error: expected '[' instead of 'x' + testscript:1:1: info: while parsing attributes 'x' + EOE + + : unknown + : + $c <>EOE != 0 + set -w [x] baz + EOI + :1:1: error: unknown value attribute x + testscript:1:1: info: while parsing attributes '[x]' + EOE + + : junk + : + $c <>EOE != 0 + set -w '[string] x' baz + EOI + :1:10: error: trailing junk after ']' + testscript:1:1: info: while parsing attributes '[string] x' + EOE +} -- cgit v1.1