aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/script.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-15 19:30:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:21 +0200
commite6932f85e8b20876f66968b31f84488eee31153d (patch)
tree570660e2701719049c16d3099128c849a9e6a190 /build2/test/script/script.cxx
parentf5090740dcb36067707ff40e0d41cdbeef15e63e (diff)
Set test variable for testscript, improve test rule
Diffstat (limited to 'build2/test/script/script.cxx')
-rw-r--r--build2/test/script/script.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index 706c87d..1b47846 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -14,6 +14,35 @@ namespace build2
{
namespace script
{
+ script::
+ script (target& tt, target& st)
+ : test_target (tt), script_target (st)
+ {
+ // 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: use the same variable type as in buildfile.
+ //
+ const variable& var (var_pool.insert<path> ("test"));
+
+ if (!find (var))
+ {
+ value& v (assign (var));
+
+ // If this is a path-based target, then we use the path. If this
+ // is a directory (alias) target, then we use the directory path.
+ // Otherwise, we leave it NULL expecting the testscript to set it
+ // to something appropriate, if used.
+ //
+ if (auto* p = tt.is_a<path_target> ())
+ v = p->path ();
+ else if (tt.is_a<dir> ())
+ v = path (tt.dir.string ()); // Strip trailing slash.
+ }
+ }
+ }
+
lookup script::
find (const variable& var) const
{