aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test/script/script.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/test/script/script.hxx')
-rw-r--r--libbuild2/test/script/script.hxx71
1 files changed, 65 insertions, 6 deletions
diff --git a/libbuild2/test/script/script.hxx b/libbuild2/test/script/script.hxx
index 2789cab..9409b01 100644
--- a/libbuild2/test/script/script.hxx
+++ b/libbuild2/test/script/script.hxx
@@ -4,8 +4,6 @@
#ifndef LIBBUILD2_TEST_SCRIPT_SCRIPT_HXX
#define LIBBUILD2_TEST_SCRIPT_SCRIPT_HXX
-#include <set>
-
#include <libbuild2/types.hxx>
#include <libbuild2/forward.hxx>
#include <libbuild2/utility.hxx>
@@ -23,13 +21,19 @@ namespace build2
namespace script
{
using build2::script::line;
+ using build2::script::line_type;
using build2::script::lines;
using build2::script::redirect;
using build2::script::redirect_type;
- using build2::script::line_type;
+ using build2::script::command;
+ using build2::script::expr_term;
using build2::script::command_expr;
+ using build2::script::iteration_index;
+ using build2::script::environment_vars;
using build2::script::deadline;
using build2::script::timeout;
+ using build2::script::pipe_command;
+ using build2::script::command_function;
class parser; // Required by VC for 'friend class parser' declaration.
@@ -93,18 +97,58 @@ namespace build2
scope_state state = scope_state::unknown;
- void
- set_variable (string&& name,
+ // The command expression execution nesting level. Can be maintained
+ // by the runner to, for example, only perform some housekeeping on
+ // the topmost level (add the test id to the diagnostics, etc).
+ //
+ // Note that the command expression execution can be nested, so that
+ // the outer expression execution is not completed before all the
+ // inner expressions are executed. As for example in:
+ //
+ // echo 'a b' | for x
+ // echo 'c d' | for y
+ // test $x $y
+ // end
+ // end
+ //
+ size_t exec_level = 0;
+
+ // Test program paths.
+ //
+ // Currently always contains a single element (see test_program() for
+ // details). While in the future there can be more of them, the zero
+ // index will always refer to the test variable value and can
+ // potentially be NULL (see reset_special() for details).
+ //
+ small_vector<const path*, 1> test_programs;
+
+ virtual void
+ set_variable (string name,
names&&,
const string& attrs,
const location&) override;
+ // Merge the command execution environment variable (un)sets from this
+ // and outer scopes.
+ //
+ virtual const environment_vars&
+ exported_variables (environment_vars& storage) override;
+
// Noop since the temporary directory is a working directory and so
// is created before the scope commands execution.
//
virtual void
create_temp_dir () override {assert (false);};
+ // Return true if this is a test program path.
+ //
+ // Note that currently the test program is only specified via the test
+ // variable ($0 effectively). In the future we may invent some other
+ // means of marking a program as a test (builtin, etc).
+ //
+ bool
+ test_program (const path&);
+
// Variables.
//
public:
@@ -283,12 +327,27 @@ namespace build2
variable_pool var_pool;
mutable shared_mutex var_pool_mutex;
+ // Used to compose a test command.
+ //
+ // Changing any of their values requires resetting the $* and $N
+ // special aliases.
+ //
const variable& test_var; // test
const variable& options_var; // test.options
const variable& arguments_var; // test.arguments
const variable& redirects_var; // test.redirects
const variable& cleanups_var; // test.cleanups
+ bool
+ test_command_var (const string& name) const
+ {
+ return name == test_var.name ||
+ name == options_var.name ||
+ name == arguments_var.name ||
+ name == redirects_var.name ||
+ name == cleanups_var.name;
+ }
+
const variable& wd_var; // $~
const variable& id_var; // $@
const variable& cmd_var; // $*
@@ -340,7 +399,7 @@ namespace build2
}
};
- std::set<path_name_value, compare_paths> paths_;
+ set<path_name_value, compare_paths> paths_;
};
}
}