aboutsummaryrefslogtreecommitdiff
path: root/build2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-05 12:02:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-05 12:02:32 +0200
commit1bb564a690e2661094e9071d4003638390a5a6fe (patch)
tree48ed8eedb1f87fd05eb66547c12349bb3db92c2b /build2/test
parent7005f1f5b525705fa3fd458a840d027046a2085b (diff)
Fix test and install rules to handle see-through groups correctly
Diffstat (limited to 'build2/test')
-rw-r--r--build2/test/rule.cxx71
-rw-r--r--build2/test/rule.hxx25
2 files changed, 45 insertions, 51 deletions
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx
index bc4060d..7c55445 100644
--- a/build2/test/rule.cxx
+++ b/build2/test/rule.cxx
@@ -56,11 +56,37 @@ namespace build2
// ---------------------------------------+-------------+---------
// test test (& pass) | pass | noop
//
+ auto& pts (t.prerequisite_targets[a]);
- // If we are passing-through, then match our prerequisites.
+ // Resolve group members.
//
- // Note that we may already have stuff in prerequisite_targets (see
- // group_rule).
+ if (!see_through || t.type ().see_through)
+ {
+ // Remember that we are called twice: first during update for test
+ // (pre-operation) and then during test. During the former, we rely on
+ // the normall update rule to resolve the group members. During the
+ // latter, there will be no rule to do this but the group will already
+ // have been resolved by the pre-operation.
+ //
+ // If the rule could not resolve the group, then we ignore it.
+ //
+ group_view gv (a.outer ()
+ ? resolve_group_members (a, t)
+ : t.group_members (a));
+
+ if (gv.members != nullptr)
+ {
+ for (size_t i (0); i != gv.count; ++i)
+ {
+ if (const target* m = gv.members[i])
+ pts.push_back (m);
+ }
+
+ match_members (a, t, pts);
+ }
+ }
+
+ // If we are passing-through, then match our prerequisites.
//
if (t.is_a<alias> () && pass (t))
{
@@ -74,7 +100,6 @@ namespace build2
match_prerequisites (a, t, t.root_scope ());
}
- auto& pts (t.prerequisite_targets[a]);
size_t pass_n (pts.size ()); // Number of pass-through prerequisites.
// See if it's testable and if so, what kind.
@@ -153,8 +178,8 @@ namespace build2
test = false;
else
{
- // Look for test input/stdin/stdout prerequisites. The same
- // group logic as in the testscript case above.
+ // Look for test input/stdin/stdout prerequisites. The same group
+ // reasoning as in the testscript case above.
//
for (prerequisite_member p:
group_prerequisite_members (a, t, members_mode::maybe))
@@ -274,40 +299,6 @@ namespace build2
}
}
- recipe group_rule::
- apply (action a, target& t) const
- {
- // Resolve group members.
- //
- // Remember that we are called twice: first during update for test
- // (pre-operation) and then during test. During the former, we rely on
- // the normall update rule to resolve the group members. During the
- // latter, there will be no rule to do this but the group will already
- // have been resolved by the pre-operation.
- //
- // If the rule could not resolve the group, then we ignore it.
- //
- group_view gv (a.outer ()
- ? resolve_group_members (a, t)
- : t.group_members (a));
-
- if (gv.members != nullptr)
- {
- auto& pts (t.prerequisite_targets[a]);
- for (size_t i (0); i != gv.count; ++i)
- {
- if (const target* m = gv.members[i])
- pts.push_back (m);
- }
-
- match_members (a, t, pts);
- }
-
- // Delegate to the base rule.
- //
- return rule::apply (a, t);
- }
-
target_state rule::
perform_update (action a, const target& t)
{
diff --git a/build2/test/rule.hxx b/build2/test/rule.hxx
index b331263..4f02390 100644
--- a/build2/test/rule.hxx
+++ b/build2/test/rule.hxx
@@ -20,9 +20,6 @@ namespace build2
class rule: public build2::rule, protected virtual common
{
public:
- explicit
- rule (common_data&& d): common (move (d)) {}
-
virtual bool
match (action, target&, const string&) const override;
@@ -37,26 +34,32 @@ namespace build2
target_state
perform_script (action, const target&, size_t) const;
+
+ rule (common_data&& d, bool see_through_only)
+ : common (move (d)), see_through (see_through_only) {}
+
+ bool see_through;
};
- class default_rule: public rule // For disambiguation in module.
+ class default_rule: public rule
{
public:
explicit
- default_rule (common_data&& d): common (move (d)), rule (move (d)) {}
+ default_rule (common_data&& d)
+ : common (move (d)),
+ rule (move (d), true /* see_through_only */) {}
};
- // In addition to the above rule's semantics, this rule sees through to
- // the group's members.
+ // To be used for non-see-through groups that should exhibit the see-
+ // through behavior for install (see lib{} in the bin module for an
+ // example).
//
class group_rule: public rule
{
public:
explicit
- group_rule (common_data&& d): common (move (d)), rule (move (d)) {}
-
- virtual recipe
- apply (action, target&) const override;
+ group_rule (common_data&& d)
+ : common (move (d)), rule (move (d), false /* see_through_only */) {}
};
}
}