diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-10-19 08:15:51 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-04 09:26:29 +0200 |
commit | 8e91d7935932066d17cf6dfb24705c5a62aa42f6 (patch) | |
tree | 8b1fa0e5edaa420151197ce5f5d1112e587cc508 | |
parent | f6cc4a1f8c33f569e37220b21ea9457ebdc69b67 (diff) |
Minor testscript fixes/changes
-rw-r--r-- | build2/test/rule.cxx | 9 | ||||
-rw-r--r-- | build2/test/script/parser.cxx | 15 | ||||
-rw-r--r-- | build2/test/script/runner.cxx | 4 | ||||
-rw-r--r-- | build2/test/script/script | 5 | ||||
-rw-r--r-- | unit-tests/test/script/lexer/script-line.test | 2 |
5 files changed, 17 insertions, 18 deletions
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx index 29d5925..7e4101c 100644 --- a/build2/test/rule.cxx +++ b/build2/test/rule.cxx @@ -354,9 +354,6 @@ namespace build2 target_state rule:: perform_script (action, target& t) { - using namespace script; - using script::script; - for (target* pt: t.prerequisite_targets) { // In case we are using the alias rule's list (see above). @@ -371,11 +368,11 @@ namespace build2 try { - script s (t, *st); - concurrent_runner r; + script::script s (t, *st); + script::concurrent_runner r; ifdstream ifs (sp); - parser p; + script::parser p; p.parse (ifs, sp, s, r); } catch (const io_error& e) diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx index b670956..e515532 100644 --- a/build2/test/script/parser.cxx +++ b/build2/test/script/parser.cxx @@ -181,10 +181,13 @@ namespace build2 // auto add_word = [&ts, &p, &hd, this] (string&& w, const location& l) { - auto add_heredoc = [&w, &hd] (redirect& r) + auto add_here_end = [&w, &hd, &l, this] (redirect& r) { + if (w.empty ()) + fail (l) << "empty here-document end marker"; + hd.push_back (r); - r.end_marker = move (w); + r.here_end = move (w); }; switch (p) @@ -205,11 +208,11 @@ namespace build2 } break; } - case pending::in_document: add_heredoc (ts.in); break; + case pending::in_document: add_here_end (ts.in); break; case pending::in_string: ts.in.value = move (w); break; - case pending::out_document: add_heredoc (ts.out); break; + case pending::out_document: add_here_end (ts.out); break; case pending::out_string: ts.out.value = move (w); break; - case pending::err_document: add_heredoc (ts.err); break; + case pending::err_document: add_here_end (ts.err); break; case pending::err_string: ts.err.value = move (w); break; } @@ -544,7 +547,7 @@ namespace build2 mode (lexer_mode::here_line); next (t, tt); - r.value = parse_here_document (t, tt, r.end_marker); + r.value = parse_here_document (t, tt, r.here_end); expire_mode (); } diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index c4778bf..25383cf 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -40,7 +40,7 @@ namespace build2 case redirect_type::here_document: { o << prefix[n - 1]; // Add another '>' or '<'. - print_string (r.end_marker); + print_string (r.here_end); break; } default: assert (false); @@ -51,7 +51,7 @@ namespace build2 { // Here-document value always ends with a newline. // - o << endl << r.value << r.end_marker; + o << endl << r.value << r.here_end; }; print_string (t.program.string ()); diff --git a/build2/test/script/script b/build2/test/script/script index 8f918fc..590013a 100644 --- a/build2/test/script/script +++ b/build2/test/script/script @@ -32,10 +32,7 @@ namespace build2 { redirect_type type = redirect_type::none; string value; - - // Meaningul for here-documents only. Used for diagnostics. - // - string end_marker; + string here_end; // Only for here-documents. }; struct command diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test index 692161b..9739cec 100644 --- a/unit-tests/test/script/lexer/script-line.test +++ b/unit-tests/test/script/lexer/script-line.test @@ -19,6 +19,8 @@ $0 $* test.options += --foo $1 +$* test.arguments += bar $2 +$* ($3 == [null]) |