From 728b075cb5e0df9c386f8377e0f6961e5ccc5143 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 16 Jun 2020 17:08:39 +0300 Subject: Add env script pseudo-builtin Also disable C++ recipe tests when cross-testing. --- tests/test/script/runner/driver.cxx | 25 +++++++++++++++++-------- tests/test/script/runner/env.testscript | 7 +++++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 tests/test/script/runner/env.testscript (limited to 'tests/test') 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 ] (-o )* (-e )* (-f )* - // (-d )* [(-t (a|m|s|z)) | (-s )] + // (-d )* (-v )* [(-t (a|m|s|z)) | (-s )] // - // 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 - // 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 - // Print the line to STDOUT. + // Print the line to stdout. // // -e - // Print the line to STDERR. + // Print the line to stderr. // // -f // 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 + // If the specified variable is set the print its value to stdout and the + // string '' otherwise. + // // -t // 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 var (getenv (v)); + cout << (var ? *var : "") << 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 >""' && env abc=xyz -- $b : unset -- cgit v1.1