diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-08 22:40:54 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-11 18:58:13 +0300 |
commit | cb558e4bd2b817bc72275c2bbd90dfe9fe380af9 (patch) | |
tree | 83bb92e3dc8a7744b30a9c9cfd12106780f24691 /tests | |
parent | ff0bf71889b041be794e8bd47d5be57f6eb07ad1 (diff) |
Add export script pseudo-builtin
Diffstat (limited to 'tests')
-rw-r--r-- | tests/recipe/buildscript/testscript | 37 | ||||
-rw-r--r-- | tests/test/script/runner/driver.cxx | 4 | ||||
-rw-r--r-- | tests/test/script/runner/export.testscript | 133 |
3 files changed, 170 insertions, 4 deletions
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript index 6bdbd32..14036dd 100644 --- a/tests/recipe/buildscript/testscript +++ b/tests/recipe/buildscript/testscript @@ -1,6 +1,8 @@ # file : tests/recipe/buildscript/testscript # license : MIT; see accompanying LICENSE file +posix = ($cxx.target.class != 'windows') + +mkdir build +cat <<EOI >=build/bootstrap.build project = test @@ -129,6 +131,37 @@ $* clean 2>- } + : export + : + if $posix + { + cat <<EOI >=bar; + #!/bin/sh + echo "$message" + EOI + + cat <<EOI >=buildfile; + exe{foo}: bar + {{ + cp $path($<) $path($>) + }} + % test + {{ + diag test $> + export message=text1 + $> >>>?'text1' + env message=text2 -- $> >>>?'text2' + }} + EOI + + $* test 2>>EOE; + cp exe{foo} + test exe{foo.} + EOE + + $* clean 2>- + } + : depdb : { @@ -442,7 +475,7 @@ : runner : - if ($cxx.target.class != 'windows') + if $posix { echo 'bar' >=bar; @@ -512,7 +545,7 @@ : timeout : -if ($cxx.target.class != 'windows') +if $posix { : update : diff --git a/tests/test/script/runner/driver.cxx b/tests/test/script/runner/driver.cxx index 935541d..f081714 100644 --- a/tests/test/script/runner/driver.cxx +++ b/tests/test/script/runner/driver.cxx @@ -66,8 +66,8 @@ main (int argc, char* argv[]) // if required. // // -v <name> - // If the specified variable is set the print its value to stdout and the - // string '<none>' otherwise. + // If the specified variable is set then print its value to stdout and + // the string '<none>' otherwise. // // -l <sec> // Sleep the specified number of seconds. diff --git a/tests/test/script/runner/export.testscript b/tests/test/script/runner/export.testscript new file mode 100644 index 0000000..f965005 --- /dev/null +++ b/tests/test/script/runner/export.testscript @@ -0,0 +1,133 @@ +# file : tests/test/script/runner/export.testscript +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: group +: +{ + : add + : + $c <<EOI && $b + { + +export foo=bar + + $* -v foo >'bar' + } + EOI + + : change + : + $c <<EOI && $b + { + +export foo=bar + +export foo=baz + + $* -v foo >'baz' + } + EOI + + : remove + : + $c <<EOI && $b + { + +export foo=bar + +export --unset foo + + $* -v foo >'<none>' + } + EOI + + : clear + : + { + : added + : + $c <<EOI && $b + { + +export foo=bar + +export --clear foo + + $* -v foo >'<none>' + } + EOI + + : removed + : + $c <<EOI && $b + { + +export foo=bar + +export --unset foo + +export --clear foo + + $* -v foo >'<none>' + } + EOI + + : non-existent + : + $c <<EOI && $b + { + +export --clear foo + + $* -v foo >'<none>' + } + EOI + } + + : override + : + $c <<EOI && $b + +export foo=bar + + { + +export --unset foo + + export foo=baz; + $* -v foo >'baz' + + -$* -v foo >'<none>' + } + + -$* -v foo >'bar' + EOI +} + +: test +: +{ + : override + : + $c <<EOI && $b + { + export foo=bar; + env foo=baz -- $* -v foo >'baz'; + $* -v foo >'bar' + } + EOI +} + +: invalid +: +{ + : set + : + $c <'export foo' && $b 2>>~%EOE% != 0 + testscript:1:1: error: export: expected variable assignment instead of 'foo' + %.+ + EOE + + : unset + : + $c <'export --unset foo=abc' && $b 2>>~%EOE% != 0 + testscript:1:1: error: export: invalid value 'foo=abc' for option -u|--unset: contains '=' + %.+ + EOE + + : clear + : + $c <'export --clear foo=abc' && $b 2>>~%EOE% != 0 + testscript:1:1: error: export: invalid value 'foo=abc' for option -c|--clear: contains '=' + %.+ + EOE +} |