aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-12-09 21:23:38 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-12-11 14:31:39 +0300
commit26af9268e98ed4c82c83b8f6e3f94af71b109eba (patch)
tree3062b7087a87f2aa145fb13db06a7db941d07db8
parent32f153664e7b6cadfb518b83e12b9768a150d709 (diff)
Fix set pseudo-builtin to reset special variables when required
-rw-r--r--libbuild2/test/script/parser.cxx11
-rw-r--r--libbuild2/test/script/script.cxx3
-rw-r--r--libbuild2/test/script/script.hxx15
-rw-r--r--tests/test/script/runner/set.testscript9
4 files changed, 28 insertions, 10 deletions
diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx
index 8179058..0a90f24 100644
--- a/libbuild2/test/script/parser.cxx
+++ b/libbuild2/test/script/parser.cxx
@@ -1415,17 +1415,8 @@ namespace build2
apply_value_attributes (&var, lhs, move (rhs), kind);
- // If we change any of the test.* values, then reset the $*, $N
- // special aliases.
- //
- 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)
- {
+ if (script_->test_command_var (var.name))
scope_->reset_special ();
- }
};
// Is set later, right before the exec_lines() call.
diff --git a/libbuild2/test/script/script.cxx b/libbuild2/test/script/script.cxx
index b539c71..32bd989 100644
--- a/libbuild2/test/script/script.cxx
+++ b/libbuild2/test/script/script.cxx
@@ -181,6 +181,9 @@ namespace build2
token_type::assign,
path_name ("<attributes>"));
}
+
+ if (root.test_command_var (var.name))
+ reset_special ();
}
// script_base
diff --git a/libbuild2/test/script/script.hxx b/libbuild2/test/script/script.hxx
index d387a11..53e4329 100644
--- a/libbuild2/test/script/script.hxx
+++ b/libbuild2/test/script/script.hxx
@@ -303,12 +303,27 @@ namespace build2
variable_pool var_pool;
mutable shared_mutex var_pool_mutex;
+ // Used to compose a test command.
+ //
+ // Changing any of their values requires resetting the $* and $N
+ // special aliases.
+ //
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
+ bool
+ test_command_var (const string& name) const
+ {
+ return name == test_var.name ||
+ name == options_var.name ||
+ name == arguments_var.name ||
+ name == redirects_var.name ||
+ name == cleanups_var.name;
+ }
+
const variable& wd_var; // $~
const variable& id_var; // $@
const variable& cmd_var; // $*
diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript
index e19cce3..b2944a3 100644
--- a/tests/test/script/runner/set.testscript
+++ b/tests/test/script/runner/set.testscript
@@ -269,6 +269,15 @@
}
}
+: special-vars
+:
+{
+ $c <<EOI && $b
+ set -w test.options <'-o foo';
+ $* >'foo'
+ EOI
+}
+
: deadline
:
{