From f4453f3dacef727cfd0fb8f17c47ac3eea367a34 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Dec 2016 12:17:44 +0200 Subject: Implement test.redirects, test.cleanups --- build2/test/init.cxx | 5 +++++ build2/test/script/parser.cxx | 8 +++++--- build2/test/script/script | 8 +++++--- build2/test/script/script.cxx | 26 ++++++++++++++++++++------ 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 ("test.roundtrip", variable_visibility::project); v.insert ("test.options", variable_visibility::project); v.insert ("test.arguments", variable_visibility::project); + + // These are only used in testscript. + // + v.insert ("test.redirects", variable_visibility::project); + v.insert ("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 ("test")), - opts_var (var_pool.insert ("test.options")), - args_var (var_pool.insert ("test.arguments")), + test_var (var_pool.insert ("test")), + options_var (var_pool.insert ("test.options")), + arguments_var (var_pool.insert ("test.arguments")), + redirects_var (var_pool.insert ("test.redirects")), + cleanups_var (var_pool.insert ("test.cleanups")), wd_var (var_pool.insert ("~")), id_var (var_pool.insert ("@")), @@ -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 (l).representation ()); - if (lookup l = find (root->opts_var)) + if (lookup l = find (root->options_var)) + append (cast (l)); + + if (lookup l = find (root->arguments_var)) + append (cast (l)); + + // Keep redirects/cleanups out of $N. + // + size_t n (s.size ()); + + if (lookup l = find (root->redirects_var)) append (cast (l)); - if (lookup l = find (root->args_var)) + if (lookup l = find (root->cleanups_var)) append (cast (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]); -- cgit v1.1