From 45709560739aa713bbac505864105bbd43c68055 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Fri, 17 Jan 2025 11:06:26 +0100 Subject: [PATCH] Print error code of failed command --- v2/status_printer.cc | 11 +++++++---- v2/status_printer.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/v2/status_printer.cc b/v2/status_printer.cc index e81fc9b5a6..c01c76499e 100644 --- a/v2/status_printer.cc +++ b/v2/status_printer.cc @@ -42,7 +42,8 @@ void StatusPrinter::BuildEdgeStarted(const Edge* edge, } void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis, - int64_t end_time_millis, bool success, + int64_t end_time_millis, + ExitStatus exit_code, const std::string& output) { ++finished_edges_; int num_removed [[maybe_unused]] = running_edges_.erase(edge); @@ -54,7 +55,7 @@ void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis, // TODO: should have stopped the timer and started it again here } - if (!success) { + if (exit_code != ExitSuccess) { ++failed_edges_; } @@ -63,14 +64,16 @@ void StatusPrinter::BuildEdgeFinished(Edge* edge, int64_t start_time_millis, } // Print the command that is spewing before printing its output. - if (!success) { + if (exit_code != ExitSuccess) { std::string outputs; for (auto o = edge->outputs_.cbegin(); o != edge->outputs_.cend(); ++o) { outputs += (*o)->path() + " "; } printer_.PrintOnNewLine( "\x1B[1;31m" - "failed: " + "failed [" + + std::to_string(exit_code) + + "]: " "\x1B[0m" + outputs + "\n"); // printer_.PrintOnNewLine(edge->EvaluateCommand() + "\n"); diff --git a/v2/status_printer.h b/v2/status_printer.h index a168374bde..112f98ed51 100644 --- a/v2/status_printer.h +++ b/v2/status_printer.h @@ -11,7 +11,7 @@ class StatusPrinter : public Status { void EdgeRemovedFromPlan(const Edge* edge) override; void BuildEdgeStarted(const Edge* edge, int64_t start_time_millis) override; void BuildEdgeFinished(Edge* edge, int64_t start_time_millis, - int64_t end_time_millis, bool success, + int64_t end_time_millis, ExitStatus, const std::string& output) override; void BuildStarted() override; void BuildFinished() override;