aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/test
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2025-02-03 06:46:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2025-02-03 06:48:19 +0200
commit43eb1e43b6b22a0343104387431db7f32a88b16c (patch)
tree15b90b59ac4748bfa923190eb91952b5a613992b /libbuild2/test
parent4ed0fe15d139748784adb40841028b36704b2f4f (diff)
Optimize maybe-used diag_record
It turns out the std::ostringstream member of butl::diag_record is quite expensive to construct but to never use.
Diffstat (limited to 'libbuild2/test')
-rw-r--r--libbuild2/test/rule.cxx16
1 files changed, 9 insertions, 7 deletions
diff --git a/libbuild2/test/rule.cxx b/libbuild2/test/rule.cxx
index 28eb35b..b3a73ce 100644
--- a/libbuild2/test/rule.cxx
+++ b/libbuild2/test/rule.cxx
@@ -745,7 +745,9 @@ namespace build2
//
auto term_pipe = [&timed_wait] (pipe_process* pp)
{
- diag_record dr;
+ // Delay the failure until we process the entire pipeline.
+ //
+ maybe_diag_record dr;
// Terminate processes gracefully and set the terminate flag for
// them.
@@ -962,7 +964,7 @@ namespace build2
//
if (!fail)
{
- diag_record dr;
+ maybe_diag_record dr;
// Note that there can be a race, so that the process we have
// terminated due to reaching the deadline has in fact exited
@@ -983,14 +985,14 @@ namespace build2
if (!pe)
{
- dr << "terminated: execution timeout expired";
+ *dr << "terminated: execution timeout expired";
if (p->unread_stderr)
dr << error << "stderr not closed after exit";
}
else if (!pe->normal () || pe->code () != 0)
{
- dr << *pe;
+ *dr << *pe;
if (p->unread_stderr)
dr << error << "stderr not closed after exit";
@@ -999,7 +1001,7 @@ namespace build2
{
assert (p->unread_stderr);
- dr << "stderr not closed after exit";
+ *dr << "stderr not closed after exit";
}
if (verb == 1)
@@ -1009,9 +1011,9 @@ namespace build2
for (pipe_process* p (b); p != nullptr; p = p->next)
{
if (p != b)
- dr << " | ";
+ *dr << " | ";
- print_process (dr, p->args);
+ print_process (*dr, p->args);
}
}
}