Skip to content

Commit

Permalink
Show skipped tests as a warning
Browse files Browse the repository at this point in the history
This matches the color used for the test outputs themselves.

Closes bazelbuild#14235.

PiperOrigin-RevId: 412987488
  • Loading branch information
brentleyjones authored and copybara-github committed Nov 29, 2021
1 parent 5fd5afa commit 59e16e9
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,30 @@ public void notify(Set<TestSummary> summaries, int numberOfExecutedTargets) {
}

private void addFailureToErrorList(List<String> list, String failureDescription, int count) {
addToErrorList(list, "fails", "fail", failureDescription, count);
addToList(list, AnsiTerminalPrinter.Mode.ERROR, "fails", "fail", failureDescription, count);
}

private void addToErrorList(
private void addToWarningList(
List<String> list, String singularPrefix, String pluralPrefix, String message, int count) {
addToList(list, AnsiTerminalPrinter.Mode.WARNING, singularPrefix, pluralPrefix, message, count);
}

private void addToList(
List<String> list,
AnsiTerminalPrinter.Mode mode,
String singularPrefix,
String pluralPrefix,
String message,
int count) {
if (count > 0) {
list.add(String.format("%s%d %s %s%s", AnsiTerminalPrinter.Mode.ERROR, count,
count == 1 ? singularPrefix : pluralPrefix, message, AnsiTerminalPrinter.Mode.DEFAULT));
list.add(
String.format(
"%s%d %s %s%s",
mode,
count,
count == 1 ? singularPrefix : pluralPrefix,
message,
AnsiTerminalPrinter.Mode.DEFAULT));
}
}

Expand Down Expand Up @@ -316,7 +332,7 @@ private void printStats(TestResultStats stats) {
addFailureToErrorList(results, "to build", stats.failedToBuildCount);
addFailureToErrorList(results, "locally", stats.failedLocallyCount);
addFailureToErrorList(results, "remotely", stats.failedRemotelyCount);
addToErrorList(results, "was", "were", "skipped", stats.noStatusCount);
addToWarningList(results, "was", "were", "skipped", stats.noStatusCount);
printer.print(
String.format(
"\nExecuted %d out of %d %s: %s.\n",
Expand Down

0 comments on commit 59e16e9

Please sign in to comment.