From 2c1aff8bf09a50189c3d0b2ff86ab057ca009749 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Feb 2017 19:56:11 +0300 Subject: Fix runner output in verbose (-v, -V) modes --- build2/test/script/runner.cxx | 30 +++++++++++++++++++++--------- build2/test/script/script.ixx | 2 +- tests/test/script/builtin/cat.test | 14 ++++++++------ tests/test/script/builtin/echo.test | 14 ++++++++------ tests/test/script/builtin/sed.test | 14 ++++++++------ 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index 751daec..4047b5a 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -761,9 +761,6 @@ namespace build2 // const command& c (*bc); - if (verb >= 3) - text << c; - // Register the command explicit cleanups. Verify that the path being // cleaned up is a sub-path of the testscript working directory. Fail // if this is not the case. @@ -1100,10 +1097,24 @@ namespace build2 bool success; + auto process_args = [&c] () -> cstrings + { + cstrings args {c.program.string ().c_str ()}; + + for (const auto& a: c.arguments) + args.push_back (a.c_str ()); + + args.push_back (nullptr); + return args; + }; + if (b != nullptr) { // Execute the builtin. // + if (verb >= 2) + print_process (process_args ()); + try { future f ( @@ -1123,12 +1134,7 @@ namespace build2 { // Execute the process. // - cstrings args {c.program.string ().c_str ()}; - - for (const auto& a: c.arguments) - args.push_back (a.c_str ()); - - args.push_back (nullptr); + cstrings args (process_args ()); try { @@ -1307,6 +1313,9 @@ namespace build2 void default_runner:: run (scope& sp, const command_expr& expr, size_t li, const location& ll) { + if (verb >= 3) + text << expr; + if (!run_expr (sp, expr, li, ll, true)) throw failed (); // Assume diagnostics is already printed. } @@ -1316,6 +1325,9 @@ namespace build2 const command_expr& expr, size_t li, const location& ll) { + if (verb >= 3) + text << "? " << expr; + return run_expr (sp, expr, li, ll, false); } } diff --git a/build2/test/script/script.ixx b/build2/test/script/script.ixx index 1b477d7..7c075fb 100644 --- a/build2/test/script/script.ixx +++ b/build2/test/script/script.ixx @@ -47,7 +47,7 @@ namespace build2 return o; } - // command_pipe + // command_expr // inline ostream& operator<< (ostream& o, const command_expr& e) diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index 33515bc..0105e7c 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -71,12 +71,14 @@ EOI : big : -: Cat a big file (about 3MB) to test that the builtin is asynchronous. +: Cat a big file (about 100K) to test that the builtin is asynchronous. : { - s="------------------------------------------------------------------------" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - $c <"cat <'$s' | cat >'$s'" && $b + $c <"$s" + EOI } diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test index 9e49a91..ac245c4 100644 --- a/tests/test/script/builtin/echo.test +++ b/tests/test/script/builtin/echo.test @@ -14,12 +14,14 @@ $c <'echo foo bar >"foo bar"' && $b : big : -: Echo a big string (about 3MB) to test that the builtin is asynchronous. +: Echo a big string (about 100K) to test that the builtin is asynchronous. : { - s="------------------------------------------------------------------------" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - $c <"echo '$s' | cat >'$s'" && $b + $c <"$s" + EOI } diff --git a/tests/test/script/builtin/sed.test b/tests/test/script/builtin/sed.test index ef99539..c0a8172 100644 --- a/tests/test/script/builtin/sed.test +++ b/tests/test/script/builtin/sed.test @@ -301,12 +301,14 @@ : big : -: Sed a big file (about 3MB) to test that the builtin is asynchronous. +: Sed a big file (about 100K) to test that the builtin is asynchronous. : { - s="------------------------------------------------------------------------" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s" - $c <"cat <'$s' | sed -e 's/^x//' >'$s'" && $b + $c <"$s" + EOI } -- cgit v1.1