From cb558e4bd2b817bc72275c2bbd90dfe9fe380af9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 8 Dec 2020 22:40:54 +0300 Subject: Add export script pseudo-builtin --- tests/test/script/runner/driver.cxx | 4 +- tests/test/script/runner/export.testscript | 133 +++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 tests/test/script/runner/export.testscript (limited to 'tests/test/script') 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 - // If the specified variable is set the print its value to stdout and the - // string '' otherwise. + // If the specified variable is set then print its value to stdout and + // the string '' otherwise. // // -l // 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 <'bar' + } + EOI + + : change + : + $c <'baz' + } + EOI + + : remove + : + $c <'' + } + EOI + + : clear + : + { + : added + : + $c <'' + } + EOI + + : removed + : + $c <'' + } + EOI + + : non-existent + : + $c <'' + } + EOI + } + + : override + : + $c <'baz' + + -$* -v foo >'' + } + + -$* -v foo >'bar' + EOI +} + +: test +: +{ + : override + : + $c <'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 +} -- cgit v1.1