aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-24 14:55:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:35 +0200
commitaa79de0b9a1e214e923139c25b02b5313a6305a9 (patch)
tree3104cdb7f0d4008c443df43beaf70aebeb8e7ec4 /build2/test/script
parent0f7ecf29943c9d8112fff923d93eeadb99a816f3 (diff)
Implement creation/cleanup of testscript root working directory
Diffstat (limited to 'build2/test/script')
-rw-r--r--build2/test/script/runner.cxx2
-rw-r--r--build2/test/script/script4
-rw-r--r--build2/test/script/script.cxx21
3 files changed, 12 insertions, 15 deletions
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
index 7377528..55c3ffe 100644
--- a/build2/test/script/runner.cxx
+++ b/build2/test/script/runner.cxx
@@ -254,7 +254,7 @@ namespace build2
path r (sp.wd_path / path (nm));
if (ci > 0)
- r += "-" + to_string (ci);
+ r += "-" + to_string (ci + 1); // Start from first line.
return r;
};
diff --git a/build2/test/script/script b/build2/test/script/script
index 44ec7c5..f1a3f50 100644
--- a/build2/test/script/script
+++ b/build2/test/script/script
@@ -217,7 +217,9 @@ namespace build2
class script: public script_base, public group
{
public:
- script (target& test_target, testscript& script_target);
+ script (target& test_target,
+ testscript& script_target,
+ const dir_path& root_wd);
public:
target& test_target; // Target we are testing.
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index 6602518..4dd47c5 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -159,19 +159,14 @@ namespace build2
}
script::
- script (target& tt, testscript& st)
+ script (target& tt, testscript& st, const dir_path& rwd)
: group (script_id (st.path ())),
test_target (tt), script_target (st)
{
// Set the script working dir ($~) to $out_base/test/<id> (id_path
- // for root is just the id).
+ // for root is just the id which is empty if st is 'testscript').
//
- {
- auto& wd (const_cast<dir_path&> (wd_path));
- wd = tt.out_dir ();
- wd /= "test";
- wd /= id_path.string ();
- }
+ const_cast<dir_path&> (wd_path) = dir_path (rwd) /= id_path.string ();
// Unless we have the test variable set on the test or script target,
// set it at the script level to the test target's path.
@@ -180,14 +175,14 @@ namespace build2
{
value& v (assign (test_var));
- // If this is a path-based target, then we use the path. If this
- // is a directory (alias) target, then we use the directory path.
- // Otherwise, we leave it NULL expecting the testscript to set it
- // to something appropriate, if used.
+ // If this is a path-based target, then we use the path. If this is
+ // an alias target (e.g., dir{}), then we use the directory path.
+ // Otherwise, we leave it NULL expecting the testscript to set it to
+ // something appropriate, if used.
//
if (auto* p = tt.is_a<path_target> ())
v = p->path ();
- else if (tt.is_a<dir> ())
+ else if (tt.is_a<alias> ())
v = path (tt.dir.string ()); // Strip trailing slash.
}