aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-09 15:40:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-09 15:40:05 +0200
commit1a46a0a1c3b0b463e13c46550998a3df1db0fdbe (patch)
treea0ac3a3d1bad08842fdc8d09a9978b722e8a813f
parent9f5c4c1ae3bff517eefb39130287016514fb31c7 (diff)
Implement test.target variable
The plan is to use it for the portable path conversions.
-rw-r--r--build/root.build4
-rw-r--r--build2/test/init.cxx47
-rw-r--r--build2/test/rule.cxx5
-rw-r--r--tests/build/root.build5
4 files changed, 42 insertions, 19 deletions
diff --git a/build/root.build b/build/root.build
index 57f70ac..78e3abd 100644
--- a/build/root.build
+++ b/build/root.build
@@ -31,3 +31,7 @@ if! $cli.configured
#
tests/exe{*}: test = true
unit-tests/exe{*}: test = true
+
+# Specify the test target for cross-testing.
+#
+test.target = $cxx.target
diff --git a/build2/test/init.cxx b/build2/test/init.cxx
index af83aea..f592568 100644
--- a/build2/test/init.cxx
+++ b/build2/test/init.cxx
@@ -37,25 +37,38 @@ namespace build2
// Enter module variables. Do it during boot in case they get assigned
// in bootstrap.build.
//
+ auto& vp (var_pool);
+
+ // Note: none are overridable.
+ //
+ // The test variable is a name which can be a path (with the
+ // true/false special values) or a target name.
+ //
+ vp.insert<name> ("test", variable_visibility::target);
+ vp.insert<name> ("test.input", variable_visibility::project);
+ vp.insert<name> ("test.output", variable_visibility::project);
+ vp.insert<name> ("test.roundtrip", variable_visibility::project);
+ vp.insert<strings> ("test.options", variable_visibility::project);
+ vp.insert<strings> ("test.arguments", variable_visibility::project);
+
+ // These are only used in testscript.
+ //
+ vp.insert<strings> ("test.redirects", variable_visibility::project);
+ vp.insert<strings> ("test.cleanups", variable_visibility::project);
+
+ // Test target platform.
+ //
+ // Unless already set, default test.target to build.host. Note that it
+ // can still be overriden by the user, e.g., in root.build.
+ //
{
- auto& v (var_pool);
+ value& v (
+ rs.assign (
+ vp.insert<target_triplet> (
+ "test.target", variable_visibility::project)));
- // Note: none are overridable.
- //
- // The test variable is a name which can be a path (with the
- // true/false special values) or a target name.
- //
- v.insert<name> ("test", variable_visibility::target);
- v.insert<name> ("test.input", variable_visibility::project);
- v.insert<name> ("test.output", variable_visibility::project);
- 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);
+ if (!v || v.empty ())
+ v = cast<target_triplet> ((*global_scope)["build.host"]);
}
}
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx
index 5851e2f..ccbf932 100644
--- a/build2/test/rule.cxx
+++ b/build2/test/rule.cxx
@@ -419,7 +419,10 @@ namespace build2
auto run = [&t, &wd] (testscript& ts)
{
if (verb)
- text << "test " << t << " with " << ts;
+ {
+ const auto& tt (cast<target_triplet> (t["test.target"]));
+ text << "test " << t << " with " << ts << " on " << tt;
+ }
script::parser p;
script::script s (t, ts, wd);
diff --git a/tests/build/root.build b/tests/build/root.build
index 2792187..1903c41 100644
--- a/tests/build/root.build
+++ b/tests/build/root.build
@@ -13,5 +13,8 @@ cxx{*}: extension = cxx
# as our $build.path).
#
import b = build2%exe{b}
-
dir{*}: test = $b
+
+# Specify the test target for cross-testing.
+#
+test.target = $cxx.target