aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/test')
-rw-r--r--libbuild2/test/script/runner.cxx23
-rw-r--r--libbuild2/test/script/script.cxx22
-rw-r--r--libbuild2/test/script/script.hxx2
3 files changed, 27 insertions, 20 deletions
diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx
index 6e722de..03a1f0e 100644
--- a/libbuild2/test/script/runner.cxx
+++ b/libbuild2/test/script/runner.cxx
@@ -13,6 +13,8 @@ namespace build2
{
namespace script
{
+ using namespace build2::script;
+
bool default_runner::
test (scope& s) const
{
@@ -49,20 +51,20 @@ namespace build2
sp.parent == nullptr
? mkdir_buildignore (
ctx,
- sp.work_dir,
+ *sp.work_dir.path,
sp.root.target_scope.root_scope ()->root_extra->buildignore_file,
2)
- : mkdir (sp.work_dir, 2));
+ : mkdir (*sp.work_dir.path, 2));
if (r == mkdir_status::already_exists)
- fail << "working directory " << sp.work_dir << " already exists" <<
+ fail << diag_path (sp.work_dir) << " already exists" <<
info << "are tests stomping on each other's feet?";
// We don't change the current directory here but indicate that the
// scope test commands will be executed in that directory.
//
if (verb >= 2)
- text << "cd " << sp.work_dir;
+ text << "cd " << *sp.work_dir.path;
}
void default_runner::
@@ -88,22 +90,23 @@ namespace build2
rmdir_status r (
sp.parent == nullptr
? rmdir_buildignore (ctx,
- sp.work_dir,
+ *sp.work_dir.path,
sp.root.target_scope.root_scope ()->
root_extra->buildignore_file,
2)
- : rmdir (ctx, sp.work_dir, 2));
+ : rmdir (ctx, *sp.work_dir.path, 2));
if (r != rmdir_status::success)
{
diag_record dr (fail (ll));
- dr << "working directory " << sp.work_dir
+
+ dr << diag_path (sp.work_dir)
<< (r == rmdir_status::not_exist
? " does not exist"
: " is not empty");
if (r == rmdir_status::not_empty)
- build2::script::print_dir (dr, sp.work_dir, ll);
+ print_dir (dr, *sp.work_dir.path, ll);
}
}
@@ -112,8 +115,8 @@ namespace build2
//
if (verb >= 2)
text << "cd " << (sp.parent != nullptr
- ? sp.parent->work_dir
- : sp.work_dir.directory ());
+ ? *sp.parent->work_dir.path
+ : sp.work_dir.path->directory ());
}
void default_runner::
diff --git a/libbuild2/test/script/script.cxx b/libbuild2/test/script/script.cxx
index 9f8cb0b..b56da1b 100644
--- a/libbuild2/test/script/script.cxx
+++ b/libbuild2/test/script/script.cxx
@@ -28,10 +28,10 @@ namespace build2
vars.assign (root.wd_var) = dir_path ();
}
- const dir_path& scope_base::
+ const dir_path* scope_base::
wd_path () const
{
- return cast<dir_path> (vars [root.wd_var]);
+ return &cast<dir_path> (vars[root.wd_var]);
}
const target_triplet& scope_base::
@@ -49,8 +49,8 @@ namespace build2
// scope
//
- static const string wd_name ("test working directory");
- static const string sd_name ("working directory");
+ static const optional<string> wd_name ("test working directory");
+ static const optional<string> sd_name ("working directory");
scope::
scope (const string& id, scope* p, script& r)
@@ -62,9 +62,11 @@ namespace build2
//
environment (root.test_target.ctx,
test_tt (),
- wd_path (), wd_name,
- p != nullptr ? root.work_dir : wd_path (), sd_name,
- wd_path (), true /* temp_dir_keep */,
+ dir_name_view (wd_path (), &wd_name),
+ dir_name_view (
+ p != nullptr ? root.work_dir.path : wd_path (),
+ &sd_name),
+ *wd_path (), true /* temp_dir_keep */,
redirect (redirect_type::none),
redirect (redirect_type::none),
redirect (redirect_type::none)),
@@ -89,7 +91,8 @@ namespace build2
// (handled in an ad hoc way).
//
if (p != nullptr)
- const_cast<dir_path&> (work_dir) = dir_path (p->work_dir) /= id;
+ const_cast<dir_path&> (*work_dir.path) =
+ dir_path (*p->work_dir.path) /= id;
}
void scope::
@@ -171,7 +174,8 @@ namespace build2
// Set the script working dir ($~) to $out_base/test/<id> (id_path
// for root is just the id which is empty if st is 'testscript').
//
- const_cast<dir_path&> (work_dir) = dir_path (rwd) /= id_path.string ();
+ const_cast<dir_path&> (*work_dir.path) =
+ dir_path (rwd) /= id_path.string ();
// Set the test variable at the script level. We do it even if it's
// set in the buildfile since they use different types.
diff --git a/libbuild2/test/script/script.hxx b/libbuild2/test/script/script.hxx
index 93846df..7bdb2ac 100644
--- a/libbuild2/test/script/script.hxx
+++ b/libbuild2/test/script/script.hxx
@@ -67,7 +67,7 @@ namespace build2
protected:
scope_base (script&);
- const dir_path&
+ const dir_path*
wd_path () const;
const target_triplet&