diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-27 14:54:16 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-04-27 14:54:16 +0200 |
commit | 2cfa969de8a275e0e65b095ed79a5f588c513bca (patch) | |
tree | 200dcb4725624dbfaed38d1459382c9279235560 | |
parent | 3813b05824fa2616b8ab9c18ed158c0c02265337 (diff) |
Redo run directive diagnostics not to rely on invalid paths
-rw-r--r-- | build2/parser.cxx | 41 | ||||
-rw-r--r-- | 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 + // <stdout>: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 ("<stdout>"), + 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 +<stdout>:1:4: error: executable name expected after run + <stdin>:1:5: info: while parsing $0 output EOE |