aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-09-13 20:47:58 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-09-27 18:04:30 +0300
commit28d1791e2dc66cc610468deb29ea030e28d0793c (patch)
treece740bad52aa15506dfeed5075771d137c3234dd /libbuild2/test
parentdbed808c7d534069f76e63a1a68a85f30d2be81c (diff)
Add support for testscript builtin escaping
Diffstat (limited to 'libbuild2/test')
-rw-r--r--libbuild2/test/script/runner.cxx27
1 files changed, 23 insertions, 4 deletions
diff --git a/libbuild2/test/script/runner.cxx b/libbuild2/test/script/runner.cxx
index 630d4c2..554edd0 100644
--- a/libbuild2/test/script/runner.cxx
+++ b/libbuild2/test/script/runner.cxx
@@ -1865,7 +1865,9 @@ namespace build2
// Resolve the relative not simple program path against the scope's
// working directory. The simple one will be left for the process
- // path search machinery.
+ // path search machinery. Also strip the potential leading `^`,
+ // indicating that this is an external program rather than a
+ // builtin.
//
path p;
@@ -1873,10 +1875,25 @@ namespace build2
{
p = path (args[0]);
- if (p.relative () && !p.simple ())
+ if (p.relative ())
{
- p = sp.wd_path / p;
- args[0] = p.string ().c_str ();
+ auto program = [&p, &args] (path pp)
+ {
+ p = move (pp);
+ args[0] = p.string ().c_str ();
+ };
+
+ if (p.simple ())
+ {
+ const string& s (p.string ());
+
+ // Don't end up with an empty path.
+ //
+ if (s.size () > 1 && s[0] == '^')
+ program (path (s, 1, s.size () - 1));
+ }
+ else
+ program (sp.wd_path / p);
}
}
catch (const invalid_path& e)
@@ -1888,6 +1905,8 @@ namespace build2
{
process_path pp (process::path_search (args[0]));
+ // Note: the builtin-escaping character '^' is not printed.
+ //
if (verb >= 2)
print_process (args);