From 28d1791e2dc66cc610468deb29ea030e28d0793c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 13 Sep 2019 20:47:58 +0300 Subject: Add support for testscript builtin escaping --- libbuild2/test/script/runner.cxx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'libbuild2') 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); -- cgit v1.1