Skip to content

Commit

Permalink
Print error code of failed command
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Jan 17, 2025
1 parent cc4802c commit 4570956
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions v2/status_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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_;
}

Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion v2/status_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4570956

Please sign in to comment.