From 2cfa969de8a275e0e65b095ed79a5f588c513bca Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Apr 2018 14:54:16 +0200 Subject: Redo run directive diagnostics not to rely on invalid paths --- build2/parser.cxx | 41 +++++++++++++---------------------------- tests/directive/run.test | 5 +++-- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/build2/parser.cxx b/build2/parser.cxx index 15235a2..bb7123c 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -1212,41 +1212,26 @@ namespace build2 // ifdstream is (move (pr.in_ofd), fdstream_mode::skip); - // Come up with a "path" that contains both the original buildfile - // location as well as the process name. The resulting diagnostics will - // look like this: + // If there is an error in the output, our diagnostics will look like + // this: // - // buildfile:10:1 (foo stdout): unterminated single quote + // :2:3 error: unterminated single quote + // buildfile:3:4 info: while parsing foo output // - path p; { - string s (l.file->string ()); - s += ':'; - - if (!ops.no_line ()) - { - s += to_string (l.line); - s += ':'; - - if (!ops.no_column ()) + auto df = make_diag_frame ( + [&args, &l](const diag_record& dr) { - s += to_string (l.column); - s += ':'; - } - } + dr << info (l) << "while parsing " << args[0] << " output"; + }); - s += " ("; - s += args[0]; - s += " stdout)"; - p = path (move (s)); + source (is, + path (""), + l, + false /* enter */, + false /* default_target */); } - source (is, - p, - l, - false /* enter */, - false /* default_target */); - is.close (); // Detect errors. } catch (const io_error&) diff --git a/tests/directive/run.test b/tests/directive/run.test index b9bfb48..507cca1 100644 --- a/tests/directive/run.test +++ b/tests/directive/run.test @@ -31,6 +31,7 @@ EOE : bad-output : cat <'print run' >=buildfile; -$* <"run '$0' noop" 2>>~%EOE% != 0 -%-:1:5: \(.+ stdout\):1:4: error: executable name expected after run% +$* <"run '$0' noop" 2>>"EOE" != 0 +:1:4: error: executable name expected after run + :1:5: info: while parsing $0 output EOE -- cgit v1.1