From 66eea6d40b7fd2c12b297f7ce55a62e02f4db291 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 1 Dec 2016 22:26:06 +0300 Subject: Make use of casts and canonicalizations in testscripts --- build2/test/script/builtin.cxx | 17 +++++++++-------- build2/test/script/runner.cxx | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'build2') diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx index b12ae7e..118f4a9 100644 --- a/build2/test/script/builtin.cxx +++ b/build2/test/script/builtin.cxx @@ -372,9 +372,9 @@ namespace build2 // rm [-r] [-f] ... // - // Remove a file or directory. A path must not be the test scope working + // Remove a file or directory. A path must not be the test working // directory or its parent directory. It also must not be outside the - // script working directory unless -f option is specified. Note that + // testscript working directory unless -f option is specified. Note that // directories are not removed by default. // // -r @@ -383,7 +383,7 @@ namespace build2 // // -f // Do not fail if path doesn't exist or no paths specified. Removing - // paths outside the script working directory is not an error. + // paths outside the testscript working directory is not an error. // // The implementation deviates from POSIX in a number of ways. It doesn't // interact with a user and fails immediatelly if unable to process an @@ -441,10 +441,11 @@ namespace build2 { path p (parse_path (*i, sp.wd_path)); - if (!p.sub (sp.root->wd_path) && !force) + const dir_path& wd (sp.root->wd_path); + if (!p.sub (wd) && !force) { - cerr << "rm: '" << p << "' is outside script working directory" - << endl; + cerr << "rm: '" << p << "' is out of working directory '" << wd + << "'" << endl; throw failed (); } @@ -462,8 +463,8 @@ namespace build2 if (sp.wd_path.sub (d)) { - cerr << "rm: '" << p << "' contains scope working directory" - << endl; + cerr << "rm: '" << p << "' contains test working directory '" + << sp.wd_path << "'" << endl; throw failed (); } diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index 8e336a3..ee059f4 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -316,8 +316,8 @@ namespace build2 }; // Register the command explicit cleanups. Verify that the path being - // cleaned up is a sub-path of the root test scope working directory. - // Fail if this is not the case. + // cleaned up is a sub-path of the testscript working directory. Fail + // if this is not the case. // for (const auto& cl: c.cleanups) { @@ -326,7 +326,7 @@ namespace build2 bool wc (np.leaf ().string () == "***"); const path& cp (wc ? np.directory () : np); - const path& wd (sp.root->wd_path); + const dir_path& wd (sp.root->wd_path); if (!cp.sub (wd)) fail (ll) << (wc -- cgit v1.1