diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-10-27 12:10:58 +0300 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-11-04 09:26:36 +0200 |
commit | adf27f5e17f4de774b3121c3669e3947ad4c9ca5 (patch) | |
tree | 8d81b3c921bd54a3358b621dd2945f36a167d03b /build2/test/script/script.cxx | |
parent | 2b8601ca72b7b3cbb3b76d96102e9607efab16b7 (diff) |
Add support of cleanups to testscript parser
Diffstat (limited to 'build2/test/script/script.cxx')
-rw-r--r-- | build2/test/script/script.cxx | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx index 8de023f..bf53595 100644 --- a/build2/test/script/script.cxx +++ b/build2/test/script/script.cxx @@ -4,6 +4,8 @@ #include <build2/test/script/script> +#include <sstream> + #include <build2/target> using namespace std; @@ -32,7 +34,19 @@ namespace build2 void to_stream (ostream& o, const command& c, command_to_stream m) { - auto print_redirect = [&o] (const redirect& r, const char* prefix) + auto print_path = [&o] (const path& p) + { + using build2::operator<<; + + ostringstream s; + stream_verb (s, stream_verb (o)); + s << p; + + to_stream_q (o, s.str ()); + }; + + auto print_redirect = + [&o, print_path] (const redirect& r, const char* prefix) { o << ' ' << prefix; @@ -72,11 +86,10 @@ namespace build2 } case redirect_type::file: { - using build2::operator<<; - // Add '>>' or '<<' (and so make it '<<<' or '>>>'). // - o << d << d << (r.file.append ? "&" : "") << r.file.path; + o << d << d << (r.file.append ? "&" : ""); + print_path (r.file.path); break; } } @@ -109,6 +122,12 @@ namespace build2 if (c.out.type != redirect_type::none) print_redirect (c.out, ">"); if (c.err.type != redirect_type::none) print_redirect (c.err, "2>"); + for (const auto& p: c.cleanups) + { + o << " &"; + print_path (p); + } + if (c.exit.comparison != exit_comparison::eq || c.exit.status != 0) { switch (c.exit.comparison) |