aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-15 12:17:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-15 12:17:44 +0200
commitf4453f3dacef727cfd0fb8f17c47ac3eea367a34 (patch)
treeb0ea119ca8ede6766659b3ffaf6eb8123ccae525
parent9d1f6b5bf5b461ce0aeb9b42b3e1022395f60d84 (diff)
Implement test.redirects, test.cleanups
-rw-r--r--build2/test/init.cxx5
-rw-r--r--build2/test/script/parser.cxx8
-rw-r--r--build2/test/script/script8
-rw-r--r--build2/test/script/script.cxx26
4 files changed, 35 insertions, 12 deletions
diff --git a/build2/test/init.cxx b/build2/test/init.cxx
index 31f6cc7..bb85464 100644
--- a/build2/test/init.cxx
+++ b/build2/test/init.cxx
@@ -48,6 +48,11 @@ namespace build2
v.insert<name> ("test.roundtrip", variable_visibility::project);
v.insert<strings> ("test.options", variable_visibility::project);
v.insert<strings> ("test.arguments", variable_visibility::project);
+
+ // These are only used in testscript.
+ //
+ v.insert<strings> ("test.redirects", variable_visibility::project);
+ v.insert<strings> ("test.cleanups", variable_visibility::project);
}
}
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 6224d24..50d4f67 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -2512,9 +2512,11 @@ namespace build2
// If we changes any of the test.* values, then reset the $*,
// $N special aliases.
//
- if (var.name == script_->test_var.name ||
- var.name == script_->opts_var.name ||
- var.name == script_->args_var.name)
+ if (var.name == script_->test_var.name ||
+ var.name == script_->options_var.name ||
+ var.name == script_->arguments_var.name ||
+ var.name == script_->redirects_var.name ||
+ var.name == script_->cleanups_var.name)
{
scope_->reset_special ();
}
diff --git a/build2/test/script/script b/build2/test/script/script
index bf882ab..d68a684 100644
--- a/build2/test/script/script
+++ b/build2/test/script/script
@@ -409,9 +409,11 @@ namespace build2
public:
variable_pool var_pool;
- const variable& test_var; // test
- const variable& opts_var; // test.options
- const variable& args_var; // test.arguments
+ const variable& test_var; // test
+ const variable& options_var; // test.options
+ const variable& arguments_var; // test.arguments
+ const variable& redirects_var; // test.redirects
+ const variable& cleanups_var; // test.cleanups
const variable& wd_var; // $~
const variable& id_var; // $@
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index f1e1bd4..7abc3b6 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -393,9 +393,11 @@ namespace build2
: // Enter the test* variables with the same variable types as in
// buildfiles.
//
- test_var (var_pool.insert<path> ("test")),
- opts_var (var_pool.insert<strings> ("test.options")),
- args_var (var_pool.insert<strings> ("test.arguments")),
+ test_var (var_pool.insert<path> ("test")),
+ options_var (var_pool.insert<strings> ("test.options")),
+ arguments_var (var_pool.insert<strings> ("test.arguments")),
+ redirects_var (var_pool.insert<strings> ("test.redirects")),
+ cleanups_var (var_pool.insert<strings> ("test.cleanups")),
wd_var (var_pool.insert<dir_path> ("~")),
id_var (var_pool.insert<path> ("@")),
@@ -441,6 +443,8 @@ namespace build2
// Unless we have the test variable set on the test or script target,
// set it at the script level to the test target's path.
//
+ // Note that test variable's visibility is target.
+ //
if (!find (test_var))
{
value& v (assign (test_var));
@@ -553,10 +557,20 @@ namespace build2
if (lookup l = find (root->test_var))
s.push_back (cast<path> (l).representation ());
- if (lookup l = find (root->opts_var))
+ if (lookup l = find (root->options_var))
+ append (cast<strings> (l));
+
+ if (lookup l = find (root->arguments_var))
+ append (cast<strings> (l));
+
+ // Keep redirects/cleanups out of $N.
+ //
+ size_t n (s.size ());
+
+ if (lookup l = find (root->redirects_var))
append (cast<strings> (l));
- if (lookup l = find (root->args_var))
+ if (lookup l = find (root->cleanups_var))
append (cast<strings> (l));
// Set the $N values if present.
@@ -565,7 +579,7 @@ namespace build2
{
value& v (assign (*root->cmdN_var[i]));
- if (i < s.size ())
+ if (i < n)
{
if (i == 0)
v = path (s[i]);