aboutsummaryrefslogtreecommitdiff
path: root/build2/test/init.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-11 10:14:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-12 10:58:19 +0200
commit9bf93c1ab73ee3cd2b763285fc5fc5456e972854 (patch)
tree0357c36e12fe2137ef6c9bd228e9d69bb2489a02 /build2/test/init.cxx
parent33ed305eac57bff406fa3f672ba8acc4941e8f13 (diff)
Implement support for narrowing down tests (config.test)
Diffstat (limited to 'build2/test/init.cxx')
-rw-r--r--build2/test/init.cxx61
1 files changed, 47 insertions, 14 deletions
diff --git a/build2/test/init.cxx b/build2/test/init.cxx
index f592568..4338231 100644
--- a/build2/test/init.cxx
+++ b/build2/test/init.cxx
@@ -9,7 +9,9 @@
#include <build2/rule>
#include <build2/diagnostics>
-#include <build2/test/rule>
+#include <build2/config/utility>
+
+#include <build2/test/module>
#include <build2/test/target>
#include <build2/test/operation>
@@ -20,9 +22,6 @@ namespace build2
{
namespace test
{
- static rule rule_;
- static alias_rule alias_rule_;
-
void
boot (scope& rs, const location&, unique_ptr<module_base>&)
{
@@ -39,6 +38,16 @@ namespace build2
//
auto& vp (var_pool);
+ // Tests to execute.
+ //
+ // Specified as <target>@<path-id> pairs with both sides being optional.
+ // The variable is untyped (we want a list of name-pairs), overridable,
+ // and inheritable. The target is relative (in essence a prerequisite)
+ // which is resolved from the (root) scope where the config.test value
+ // is defined.
+ //
+ vp.insert ("config.test", true);
+
// Note: none are overridable.
//
// The test variable is a name which can be a path (with the
@@ -76,7 +85,7 @@ namespace build2
init (scope& rs,
scope&,
const location& l,
- unique_ptr<module_base>&,
+ unique_ptr<module_base>& mod,
bool first,
bool,
const variable_map& config_hints)
@@ -92,16 +101,39 @@ namespace build2
const dir_path& out_root (rs.out_path ());
l5 ([&]{trace << "for " << out_root;});
- assert (config_hints.empty ()); // We don't known any hints.
+ assert (mod == nullptr);
+ mod.reset (new module ());
+ module& m (static_cast<module&> (*mod));
- //@@ TODO: Need ability to specify extra diff options (e.g.,
- // --strip-trailing-cr, now hardcoded).
+ // Configure.
+ //
+ assert (config_hints.empty ()); // We don't known any hints.
// Adjust module priority so that the config.test.* values are saved at
// the end of config.build.
//
- // if (s)
- // config::save_module (r, "test", INT32_MAX);
+ config::save_module (rs, "test", INT32_MAX);
+
+ // config.test
+ //
+ if (lookup l = config::omitted (rs, "config.test").first)
+ {
+ // Figure out which root scope it came from.
+ //
+ scope* s (&rs);
+ for (;
+ s != nullptr && !l.belongs (*s);
+ s = s->parent_scope ()->root_scope ())
+ assert (s != nullptr);
+
+ m.test_ = &cast<names> (l);
+ m.root_ = s;
+ }
+
+ //@@ TODO: Need ability to specify extra diff options (e.g.,
+ // --strip-trailing-cr, now hardcoded).
+ //
+ //@@ TODO: Pring report.
// Register target types.
//
@@ -114,18 +146,19 @@ namespace build2
// Register rules.
//
{
- auto& r (rs.rules);
+ rule& r (m);
+ alias_rule& ar (m);
// Register our test running rule.
//
- r.insert<target> (perform_test_id, "test", rule_);
- r.insert<alias> (perform_test_id, "test", alias_rule_);
+ rs.rules.insert<target> (perform_test_id, "test", r);
+ rs.rules.insert<alias> (perform_test_id, "test", ar);
// Register our rule for the dist meta-operation. We need to do this
// because we may have ad hoc prerequisites (test input/output files)
// that need to be entered into the target list.
//
- r.insert<target> (dist_id, test_id, "test", rule_);
+ rs.rules.insert<target> (dist_id, test_id, "test", r);
}
return true;