Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic committed Dec 4, 2024
1 parent dc3327d commit 071b2a3
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions tooling/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,40 +281,33 @@ fn display_test_report(
let plural_failed = if count_failed == 1 { "" } else { "s" };
let plural_passed = if count_passed == 1 { "" } else { "s" };
let plural_skipped = if count_skipped == 1 { "" } else { "s" };

if count_failed == 0 {
let mut previous = false;
if count_passed > 0 {
writer.set_color(ColorSpec::new().set_fg(Some(Color::Green))).expect("Failed to set color");
write!(writer, "{count_passed} test{plural_passed} passed")
write!(writer, "{count_passed} test{plural_passed} passed",)
.expect("Failed to write to stderr");
if count_skipped > 0 {
writer
.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))
.expect("Failed to set color");
write!(writer, ", {count_skipped} test{plural_skipped} skipped")
.expect("Failed to write to stderr");
}
writer.reset().expect("Failed to reset writer");
writeln!(writer).expect("Failed to write to stderr");
} else {
if count_passed != 0 {
writer
.set_color(ColorSpec::new().set_fg(Some(Color::Green)))
.expect("Failed to set color");
write!(writer, "{count_passed} test{plural_passed} passed, ",)
.expect("Failed to write to stderr");
}
if count_skipped != 0 {
writer
.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))
.expect("Failed to set color");
write!(writer, ", {count_skipped} test{plural_skipped} skipped")
.expect("Failed to write to stderr");
previous = true;
}
if count_skipped > 0 {
writer
.set_color(ColorSpec::new().set_fg(Some(Color::Yellow)))
.expect("Failed to set color");
if previous {
write!(writer, ", ").expect("Failed to write to stderr");
}
write!(writer, "{count_skipped} test{plural_skipped} skipped")
.expect("Failed to write to stderr");
previous = true;
}
if count_failed > 0 {
writer.set_color(ColorSpec::new().set_fg(Some(Color::Red))).expect("Failed to set color");
writeln!(writer, "{count_failed} test{plural_failed} failed")
if previous {
write!(writer, ", ").expect("Failed to write to stderr");
}
write!(writer, "{count_failed} test{plural_failed} failed")
.expect("Failed to write to stderr");
writer.reset().expect("Failed to reset writer");
}

writeln!(writer).expect("Failed to write to stderr");
writer.reset().expect("Failed to reset writer");
Ok(())
}

0 comments on commit 071b2a3

Please sign in to comment.