aboutsummaryrefslogtreecommitdiff
path: root/build2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-07 08:09:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:42 +0200
commit7b9eb752cad04aaadc4552d0f26d307b04af1869 (patch)
treed19cdb450ddec384ec41d9129f8d4afecc14acb7 /build2/test
parentbe773edfa2c8f8f3230509bbd713542d20fbb37e (diff)
Pass const target& to recipes
Diffstat (limited to 'build2/test')
-rw-r--r--build2/test/common6
-rw-r--r--build2/test/common.cxx6
-rw-r--r--build2/test/rule6
-rw-r--r--build2/test/rule.cxx32
-rw-r--r--build2/test/script/script8
-rw-r--r--build2/test/script/script.cxx4
6 files changed, 33 insertions, 29 deletions
diff --git a/build2/test/common b/build2/test/common
index d3678c8..44c7bf8 100644
--- a/build2/test/common
+++ b/build2/test/common
@@ -25,18 +25,18 @@ namespace build2
// prerequisites.
//
bool
- pass (target& alias_target) const;
+ pass (const target& alias_target) const;
// Return true if the specified target should be tested.
//
bool
- test (target& test_target) const;
+ test (const target& test_target) const;
// Return true if the specified target should be tested with the
// specified testscript test (or group).
//
bool
- test (target& test_target, const path& id_path) const;
+ test (const target& test_target, const path& id_path) const;
};
}
}
diff --git a/build2/test/common.cxx b/build2/test/common.cxx
index 1b4c194..be0e690 100644
--- a/build2/test/common.cxx
+++ b/build2/test/common.cxx
@@ -55,7 +55,7 @@ namespace build2
}
bool common::
- pass (target& a) const
+ pass (const target& a) const
{
if (test_ == nullptr)
return true;
@@ -95,7 +95,7 @@ namespace build2
}
bool common::
- test (target& t) const
+ test (const target& t) const
{
if (test_ == nullptr)
return true;
@@ -159,7 +159,7 @@ namespace build2
}
bool common::
- test (target& t, const path& id) const
+ test (const target& t, const path& id) const
{
if (test_ == nullptr)
return true;
diff --git a/build2/test/rule b/build2/test/rule
index 0e208ff..da55173 100644
--- a/build2/test/rule
+++ b/build2/test/rule
@@ -24,7 +24,7 @@ namespace build2
match (slock&, action, target&, const string&) const override;
target_state
- perform_script (action, target&) const;
+ perform_script (action, const target&) const;
};
class rule: public rule_common
@@ -34,7 +34,7 @@ namespace build2
apply (slock&, action, target&) const override;
static target_state
- perform_test (action, target&);
+ perform_test (action, const target&);
};
class alias_rule: public rule_common
@@ -44,7 +44,7 @@ namespace build2
apply (slock&, action, target&) const override;
target_state
- perform_test (action, target&) const;
+ perform_test (action, const target&) const;
};
}
}
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx
index 05d5eac..38c24f9 100644
--- a/build2/test/rule.cxx
+++ b/build2/test/rule.cxx
@@ -186,7 +186,7 @@ namespace build2
// If not a test then also redirect to the alias rule.
//
return md.test
- ? [this] (action a, target& t) {return perform_test (a, t);}
+ ? [this] (action a, const target& t) {return perform_test (a, t);}
: default_recipe;
}
@@ -218,7 +218,10 @@ namespace build2
t.prerequisite_targets.push_back (&p.search ());
}
- return [this] (action a, target& t) {return perform_script (a, t);};
+ return [this] (action a, const target& t)
+ {
+ return perform_script (a, t);
+ };
}
else
{
@@ -327,7 +330,8 @@ namespace build2
// update of input/output targets and also delegate to the real
// update.
//
- return [it, ot, dr = move (d)] (action a, target& t) -> target_state
+ return [it, ot, dr = move (d)] (
+ action a, const target& t) -> target_state
{
// Do the general update first.
//
@@ -363,7 +367,7 @@ namespace build2
}
target_state rule_common::
- perform_script (action, target& t) const
+ perform_script (action, const target& t) const
{
// Figure out whether the testscript file is called 'testscript', in
// which case it should be the only one.
@@ -371,11 +375,11 @@ namespace build2
bool one;
{
optional<bool> o;
- for (target* pt: t.prerequisite_targets)
+ for (const target* pt: t.prerequisite_targets)
{
// In case we are using the alias rule's list (see above).
//
- if (testscript* ts = pt->is_a<testscript> ())
+ if (const testscript* ts = pt->is_a<testscript> ())
{
bool r (ts->name == "testscript");
@@ -435,9 +439,9 @@ namespace build2
// Run all the testscripts.
//
- for (target* pt: t.prerequisite_targets)
+ for (const target* pt: t.prerequisite_targets)
{
- if (testscript* ts = pt->is_a<testscript> ())
+ if (const testscript* ts = pt->is_a<testscript> ())
{
// If this is just the testscript, then its id path is empty (and
// it can only be ignored by ignoring the test target, which makes
@@ -489,7 +493,7 @@ namespace build2
// nameN arg arg ... nullptr nullptr
//
static bool
- run_test (target& t,
+ run_test (const target& t,
diag_record& dr,
char const** args,
process* prev = nullptr)
@@ -547,7 +551,7 @@ namespace build2
}
target_state rule::
- perform_test (action, target& tt)
+ perform_test (action, const target& tt)
{
// @@ Would be nice to print what signal/core was dumped.
//
@@ -562,7 +566,7 @@ namespace build2
// Note that we have similar code for scripted tests.
//
- target* t (nullptr);
+ const target* t (nullptr);
if (l.defined ())
{
@@ -636,7 +640,7 @@ namespace build2
auto& pts (tt.prerequisite_targets);
if (pts.size () != 0 && pts[0] != nullptr)
{
- file& it (static_cast<file&> (*pts[0]));
+ const file& it (static_cast<const file&> (*pts[0]));
assert (!it.path ().empty ()); // Should have been assigned by update.
args.push_back (it.path ().string ().c_str ());
}
@@ -656,7 +660,7 @@ namespace build2
process_path dpp;
if (pts.size () != 0 && pts[1] != nullptr)
{
- file& ot (static_cast<file&> (*pts[1]));
+ const file& ot (static_cast<const file&> (*pts[1]));
assert (!ot.path ().empty ()); // Should have been assigned by update.
dpp = run_search (dp, true);
@@ -693,7 +697,7 @@ namespace build2
}
target_state alias_rule::
- perform_test (action a, target& t) const
+ perform_test (action a, const target& t) const
{
// Run the alias recipe first then the test.
//
diff --git a/build2/test/script/script b/build2/test/script/script
index e528cdd..2438fa5 100644
--- a/build2/test/script/script
+++ b/build2/test/script/script
@@ -511,8 +511,8 @@ namespace build2
class script: public script_base, public group
{
public:
- script (target& test_target,
- testscript& script_target,
+ script (const target& test_target,
+ const testscript& script_target,
const dir_path& root_wd);
script (script&&) = delete;
@@ -521,8 +521,8 @@ namespace build2
script& operator= (const script&) = delete;
public:
- target& test_target; // Target we are testing.
- testscript& script_target; // Target of the testscript file.
+ const target& test_target; // Target we are testing.
+ const testscript& script_target; // Target of the testscript file.
// Pre-parse data.
//
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index bd13845..bc816d7 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -500,7 +500,7 @@ namespace build2
// script
//
script::
- script (target& tt, testscript& st, const dir_path& rwd)
+ script (const target& tt, const testscript& st, const dir_path& rwd)
: group (st.name == "testscript" ? string () : st.name),
test_target (tt),
script_target (st)
@@ -522,7 +522,7 @@ namespace build2
// Note that we have similar code for simple tests.
//
- target* t (nullptr);
+ const target* t (nullptr);
if (l.defined ())
{