aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test/script/runner.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/test/script/runner.cxx')
-rw-r--r--libbuild2/test/script/runner.cxx73
1 files changed, 55 insertions, 18 deletions
diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx
index 03a1f0e..98d6868 100644
--- a/libbuild2/test/script/runner.cxx
+++ b/libbuild2/test/script/runner.cxx
@@ -3,6 +3,8 @@
#include <libbuild2/test/script/runner.hxx>
+#include <libbuild2/filesystem.hxx>
+
#include <libbuild2/script/run.hxx>
#include <libbuild2/test/common.hxx>
@@ -21,6 +23,12 @@ namespace build2
return common_.test (s.root.test_target, s.id_path);
}
+ pair<const process_path*, const strings*> default_runner::
+ test_runner ()
+ {
+ return make_pair (common_.runner_path, common_.runner_options);
+ }
+
void default_runner::
enter (scope& sp, const location&)
{
@@ -35,6 +43,18 @@ namespace build2
dr << info << "test id: " << sp.id_path.posix_string ();
});
+ // Note that we could probably keep the test programs sets fully
+ // independent across the scopes and check if the program is a test by
+ // traversing the scopes upwards recursively. Note though, that the
+ // parent scope's set cannot change during the nested scope execution
+ // and normally contains just a single entry. Thus, it seems more
+ // efficient to get rid of the recursion by copying the set from the
+ // parent now and potentially changing it later on the test variable
+ // assignment, etc.
+ //
+ if (sp.parent != nullptr)
+ sp.test_programs = sp.parent->test_programs;
+
// Scope working directory shall be empty (the script working
// directory is cleaned up by the test rule prior the script
// execution).
@@ -122,7 +142,9 @@ namespace build2
void default_runner::
run (scope& sp,
const command_expr& expr, command_type ct,
- size_t li, const location& ll)
+ const iteration_index* ii, size_t li,
+ const function<command_function>& cf,
+ const location& ll)
{
// Noop for teardown commands if keeping tests output is requested.
//
@@ -144,40 +166,55 @@ namespace build2
text << ": " << c << expr;
}
- // Print test id once per test expression.
+ // Print test id once per test expression and only for the topmost
+ // one.
//
auto df = make_diag_frame (
- [&sp](const diag_record& dr)
+ [&sp, print = (sp.exec_level == 0)](const diag_record& dr)
{
- // Let's not depend on how the path representation can be improved
- // for readability on printing.
- //
- dr << info << "test id: " << sp.id_path.posix_string ();
+ if (print)
+ {
+ // Let's not depend on how the path representation can be
+ // improved for readability on printing.
+ //
+ dr << info << "test id: " << sp.id_path.posix_string ();
+ }
});
- build2::script::run (sp, expr, li, ll);
+ ++sp.exec_level;
+ build2::script::run (sp, expr, ii, li, ll, cf);
+ --sp.exec_level;
}
bool default_runner::
- run_if (scope& sp,
- const command_expr& expr,
- size_t li, const location& ll)
+ run_cond (scope& sp,
+ const command_expr& expr,
+ const iteration_index* ii, size_t li,
+ const location& ll)
{
if (verb >= 3)
text << ": ?" << expr;
- // Print test id once per test expression.
+ // Print test id once per test expression and only for the topmost
+ // one.
//
auto df = make_diag_frame (
- [&sp](const diag_record& dr)
+ [&sp, print = (sp.exec_level == 0)](const diag_record& dr)
{
- // Let's not depend on how the path representation can be improved
- // for readability on printing.
- //
- dr << info << "test id: " << sp.id_path.posix_string ();
+ if (print)
+ {
+ // Let's not depend on how the path representation can be
+ // improved for readability on printing.
+ //
+ dr << info << "test id: " << sp.id_path.posix_string ();
+ }
});
- return build2::script::run_if (sp, expr, li, ll);
+ ++sp.exec_level;
+ bool r (build2::script::run_cond (sp, expr, ii, li, ll));
+ --sp.exec_level;
+
+ return r;
}
}
}