aboutsummaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-06-16 17:08:39 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-18 14:18:59 +0300
commit728b075cb5e0df9c386f8377e0f6961e5ccc5143 (patch)
tree8bd60cb16a260031d46b5d79adab5821dac3dd27 /tests/test
parent448747903956f70f85f5135a224bbbae7f7b276a (diff)
Add env script pseudo-builtin
Also disable C++ recipe tests when cross-testing.
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/script/runner/driver.cxx25
-rw-r--r--tests/test/script/runner/env.testscript7
2 files changed, 24 insertions, 8 deletions
diff --git a/tests/test/script/runner/driver.cxx b/tests/test/script/runner/driver.cxx
index 08d5bba..d5a74a4 100644
--- a/tests/test/script/runner/driver.cxx
+++ b/tests/test/script/runner/driver.cxx
@@ -34,22 +34,22 @@ main (int argc, char* argv[])
using butl::optional;
// Usage: driver [-i <int>] (-o <string>)* (-e <string>)* (-f <file>)*
- // (-d <dir>)* [(-t (a|m|s|z)) | (-s <int>)]
+ // (-d <dir>)* (-v <name>)* [(-t (a|m|s|z)) | (-s <int>)]
//
- // Execute actions specified by -i, -o, -e, -f, -d options in the order as
- // they appear on the command line. After that terminate abnormally if -t
- // option is provided, otherwise exit normally with the status specified by
- // -s option (0 by default).
+ // Execute actions specified by -i, -o, -e, -f, -d, and -v options in the
+ // order as they appear on the command line. After that terminate abnormally
+ // if -t option is provided, otherwise exit normally with the status
+ // specified by -s option (0 by default).
//
// -i <fd>
- // Forward STDIN data to the standard stream denoted by the file
+ // Forward stdin data to the standard stream denoted by the file
// descriptor. Read and discard if 0.
//
// -o <string>
- // Print the line to STDOUT.
+ // Print the line to stdout.
//
// -e <string>
- // Print the line to STDERR.
+ // Print the line to stderr.
//
// -f <path>
// Create an empty file with the path specified.
@@ -58,6 +58,10 @@ main (int argc, char* argv[])
// Create a directory with the path specified. Create parent directories
// if required.
//
+ // -v <name>
+ // If the specified variable is set the print its value to stdout and the
+ // string '<none>' otherwise.
+ //
// -t <method>
// Abnormally terminate itself using one of the following methods:
//
@@ -135,6 +139,11 @@ main (int argc, char* argv[])
{
try_mkdir_p (dir_path (v));
}
+ else if (o == "-v")
+ {
+ optional<string> var (getenv (v));
+ cout << (var ? *var : "<none>") << endl;
+ }
else if (o == "-t")
{
assert (aterm == '\0' && !status); // Make sure exit method is not set.
diff --git a/tests/test/script/runner/env.testscript b/tests/test/script/runner/env.testscript
new file mode 100644
index 0000000..6fcedfa
--- /dev/null
+++ b/tests/test/script/runner/env.testscript
@@ -0,0 +1,7 @@
+# file : tests/test/script/runner/env.testscript
+# license : MIT; see accompanying LICENSE file
+
+.include ../common.testscript
+
+$c <'env abc=xyz -- $* -v abc >xyz' && $b : set
+$c <'env --unset=abc -- $* -v abc >"<none>"' && env abc=xyz -- $b : unset