aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/runner.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-19 16:41:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:33 +0200
commita17e517e079c33bcb4d6dea94f6c441a5eb2e33a (patch)
tree52a529d7b54513aa88417e1f7a49e24a5893ecef /build2/test/script/runner.cxx
parent43124ef418bd7fe909027b977bf5effc305b4740 (diff)
Generalize and move test printing code to script
Diffstat (limited to 'build2/test/script/runner.cxx')
-rw-r--r--build2/test/script/runner.cxx75
1 files changed, 0 insertions, 75 deletions
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
index 25383cf..3a5eb76 100644
--- a/build2/test/script/runner.cxx
+++ b/build2/test/script/runner.cxx
@@ -12,81 +12,6 @@ namespace build2
{
namespace script
{
- static ostream&
- operator<< (ostream& o, const test& t)
- {
- auto print_string = [&o] (const string& s)
- {
- // Quote if empty or contains spaces.
- //
- if (s.empty () || s.find (' ') != string::npos)
- o << '"' << s << '"';
- else
- o << s;
- };
-
- auto print_redirect = [&o, &print_string] (const redirect& r,
- const char* prefix)
- {
- o << ' ' << prefix;
-
- size_t n (string::traits_type::length (prefix));
- assert (n > 0);
-
- switch (r.type)
- {
- case redirect_type::null: o << '!'; break;
- case redirect_type::here_string: print_string (r.value); break;
- case redirect_type::here_document:
- {
- o << prefix[n - 1]; // Add another '>' or '<'.
- print_string (r.here_end);
- break;
- }
- default: assert (false);
- }
- };
-
- auto print_heredoc = [&o] (const redirect& r)
- {
- // Here-document value always ends with a newline.
- //
- o << endl << r.value << r.here_end;
- };
-
- print_string (t.program.string ());
-
- for (const auto& a: t.arguments)
- {
- o << ' ';
- print_string (a);
- }
-
- if (t.in.type != redirect_type::none)
- print_redirect (t.in, "<");
-
- if (t.out.type != redirect_type::none)
- print_redirect (t.out, ">");
-
- if (t.err.type != redirect_type::none)
- print_redirect (t.err, "2>");
-
- if (t.exit.comparison != exit_comparison::eq || t.exit.status != 0)
- o << (t.exit.comparison == exit_comparison::eq ? " == " : " != ")
- << (int)t.exit.status;
-
- if (t.in.type == redirect_type::here_document)
- print_heredoc (t.in);
-
- if (t.out.type == redirect_type::here_document)
- print_heredoc (t.out);
-
- if (t.err.type == redirect_type::here_document)
- print_heredoc (t.err);
-
- return o;
- }
-
static void
print_test (diag_record& r, const test& t)
{