aboutsummaryrefslogtreecommitdiff
path: root/build2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:06:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-03-07 09:06:37 +0200
commit1845141809aa91b03718066a6f46863885a6a887 (patch)
treea3f542ec7c1781e65aa16a9b0d5c31eae4c4d757 /build2/test
parente0002617846755fb5f199f40a677e16d6f69e5ec (diff)
Add support for alternative build file/directory naming scheme
Now the build/*.build, buildfile, and .buildignore filesystem entries in a project can alternatively (but consistently) be called build2/*.build2, build2file, and .build2ignore. See a note at the beginning of the Project Structure section in the manual for details (motivation, restrictions, etc).
Diffstat (limited to 'build2/test')
-rw-r--r--build2/test/rule.cxx13
-rw-r--r--build2/test/script/runner.cxx24
-rw-r--r--build2/test/script/script.cxx6
-rw-r--r--build2/test/script/script.hxx5
-rw-r--r--build2/test/target.cxx2
5 files changed, 31 insertions, 19 deletions
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx
index 2ff7ebf..941609d 100644
--- a/build2/test/rule.cxx
+++ b/build2/test/rule.cxx
@@ -437,9 +437,11 @@ namespace build2
// backlink_*() in algorithm.cxx for details.)
//
const scope& bs (t.base_scope ());
+ const scope& rs (*bs.root_scope ());
+ const path& buildignore_file (rs.root_extra->buildignore_file);
dir_path bl;
- if (cast_false<bool> (bs.root_scope ()->vars[var_forwarded]))
+ if (cast_false<bool> (rs.vars[var_forwarded]))
{
bl = bs.src_path () / wd.leaf (bs.out_path ());
clean_backlink (bl, verb_never);
@@ -471,10 +473,11 @@ namespace build2
bool fail (before == output_before::fail);
(fail ? error : warn) << "working directory " << wd << " exists "
- << (empty_buildignore (wd)
+ << (empty_buildignore (wd, buildignore_file)
? ""
: "and is not empty ")
<< "at the beginning of the test";
+
if (fail)
throw failed ();
}
@@ -513,7 +516,7 @@ namespace build2
{
if (mk)
{
- mkdir_buildignore (wd, 2);
+ mkdir_buildignore (wd, buildignore_file, 2);
mk = false;
}
@@ -568,11 +571,11 @@ namespace build2
//
if (!bad && !one && !mk && after == output_after::clean)
{
- if (!empty_buildignore (wd))
+ if (!empty_buildignore (wd, buildignore_file))
fail << "working directory " << wd << " is not empty at the "
<< "end of the test";
- rmdir_buildignore (wd, 2);
+ rmdir_buildignore (wd, buildignore_file, 2);
}
// Backlink if the working directory exists.
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
index c881031..0d3716f 100644
--- a/build2/test/script/runner.cxx
+++ b/build2/test/script/runner.cxx
@@ -719,9 +719,13 @@ namespace build2
// alike utility functions so the failure message can contain
// location info?
//
- fs_status<mkdir_status> r (sp.parent == nullptr
- ? mkdir_buildignore (sp.wd_path, 2)
- : mkdir (sp.wd_path, 2));
+ fs_status<mkdir_status> r (
+ sp.parent == nullptr
+ ? mkdir_buildignore (
+ sp.wd_path,
+ sp.root->target_scope.root_scope ()->root_extra->buildignore_file,
+ 2)
+ : mkdir (sp.wd_path, 2));
if (r == mkdir_status::already_exists)
fail << "working directory " << sp.wd_path << " already exists" <<
@@ -914,11 +918,15 @@ namespace build2
// a file cleanup when try to rmfile() directory instead of
// file.
//
- rmdir_status r (recursive
- ? rmdir_r (d, !wd, static_cast <uint16_t> (v))
- : wd && sp.parent == nullptr
- ? rmdir_buildignore (d, v)
- : rmdir (d, v));
+ rmdir_status r (
+ recursive
+ ? rmdir_r (d, !wd, static_cast <uint16_t> (v))
+ : (wd && sp.parent == nullptr
+ ? rmdir_buildignore (
+ d,
+ sp.root->target_scope.root_scope ()->root_extra->buildignore_file,
+ v)
+ : rmdir (d, v)));
if (r == rmdir_status::success ||
(r == rmdir_status::not_exist && t == cleanup_type::maybe))
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index f2a8d03..94d6d8b 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -517,6 +517,7 @@ namespace build2
const dir_path& rwd)
: group (st.name == "testscript" ? string () : st.name, this),
test_target (tt),
+ target_scope (tt.base_scope ()),
script_target (st)
{
// Set the script working dir ($~) to $out_base/test/<id> (id_path
@@ -563,7 +564,7 @@ namespace build2
//
// @@ OUT: what if this is a @-qualified pair of names?
//
- t = search_existing (*n, tt.base_scope ());
+ t = search_existing (*n, target_scope);
if (t == nullptr)
fail << "unknown target '" << *n << "' in test variable";
@@ -653,8 +654,7 @@ namespace build2
if (p.first)
{
if (var.override != nullptr)
- p = s.test_target.base_scope ().find_override (
- var, move (p), true);
+ p = s.target_scope.find_override (var, move (p), true);
return p.first;
}
diff --git a/build2/test/script/script.hxx b/build2/test/script/script.hxx
index 479001b..4da9d97 100644
--- a/build2/test/script/script.hxx
+++ b/build2/test/script/script.hxx
@@ -536,8 +536,9 @@ namespace build2
script& operator= (const script&) = delete;
public:
- const target& test_target; // Target we are testing.
- const testscript& script_target; // Target of the testscript file.
+ const target& test_target; // Target we are testing.
+ const build2::scope& target_scope; // Base scope of test target.
+ const testscript& script_target; // Target of the testscript file.
// Pre-parse data.
//
diff --git a/build2/test/target.cxx b/build2/test/target.cxx
index c440325..f75b556 100644
--- a/build2/test/target.cxx
+++ b/build2/test/target.cxx
@@ -12,7 +12,7 @@ namespace build2
namespace test
{
static const char*
- testscript_target_extension (const target_key& tk)
+ testscript_target_extension (const target_key& tk, const scope*)
{
// If the name is special 'testscript', then there is no extension,
// otherwise it is .testscript.