Skip to content

Commit b1eb51c

Browse files
authored
Rollup merge of rust-lang#113518 - jyn514:streaming-failures, r=cuviper
bootstrap/libtest: print test name eagerly on failure even with `verbose-tests=false` / `--quiet` Previously, libtest would wait until all tests finished running to print the progress, which made it annoying to run many tests at once (since you don't know which have failed). Change it to print the names as soon as they fail. This makes it much easier to know which test failed without having to wait for compiletest to completely finish running. Before: ``` Testing stage0 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu) running 15274 tests iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 88/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 176/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 264/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 352/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 440/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 528/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiFFiiiiiii ... ``` After: ``` Testing stage0 compiletest suite=ui mode=ui (x86_64-unknown-linux-gnu) running 15274 tests iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 88/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 176/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 264/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 352/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 440/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 528/15274 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii [ui] tests/ui/associated-type-bounds/implied-in-supertrait.rs ... F [ui] tests/ui/associated-type-bounds/return-type-notation/basic.rs#next_with ... F iiiiiiiiiiiii ... ``` This serves a similar use case to the existing RUSTC_TEST_FAIL_FAST, but is on by default and as a result much more discoverable. We should consider unifying RUSTC_TEST_FAIL_FAST with the `--no-fail-fast` flag in the future for consistency and discoverability.
2 parents b5eea9f + 17c9c50 commit b1eb51c

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

test/src/formatters/terse.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) struct TerseFormatter<T> {
2323
max_name_len: usize,
2424

2525
test_count: usize,
26+
test_column: usize,
2627
total_test_count: usize,
2728
}
2829

@@ -39,6 +40,7 @@ impl<T: Write> TerseFormatter<T> {
3940
max_name_len,
4041
is_multithreaded,
4142
test_count: 0,
43+
test_column: 0,
4244
total_test_count: 0, // initialized later, when write_run_start is called
4345
}
4446
}
@@ -47,8 +49,20 @@ impl<T: Write> TerseFormatter<T> {
4749
self.write_short_result(".", term::color::GREEN)
4850
}
4951

50-
pub fn write_failed(&mut self) -> io::Result<()> {
51-
self.write_short_result("F", term::color::RED)
52+
pub fn write_failed(&mut self, name: &str) -> io::Result<()> {
53+
// Put failed tests on their own line and include the test name, so that it's faster
54+
// to see which test failed without having to wait for them all to run.
55+
56+
// normally, we write the progress unconditionally, even if the previous line was cut short.
57+
// but if this is the very first column, no short results will have been printed and we'll end up with *only* the progress on the line.
58+
// avoid this.
59+
if self.test_column != 0 {
60+
self.write_progress()?;
61+
}
62+
self.test_count += 1;
63+
self.write_plain(format!("{name} --- "))?;
64+
self.write_pretty("FAILED", term::color::RED)?;
65+
self.write_plain("\n")
5266
}
5367

5468
pub fn write_ignored(&mut self) -> io::Result<()> {
@@ -65,15 +79,22 @@ impl<T: Write> TerseFormatter<T> {
6579
color: term::color::Color,
6680
) -> io::Result<()> {
6781
self.write_pretty(result, color)?;
68-
if self.test_count % QUIET_MODE_MAX_COLUMN == QUIET_MODE_MAX_COLUMN - 1 {
82+
self.test_count += 1;
83+
self.test_column += 1;
84+
if self.test_column % QUIET_MODE_MAX_COLUMN == QUIET_MODE_MAX_COLUMN - 1 {
6985
// We insert a new line regularly in order to flush the
7086
// screen when dealing with line-buffered output (e.g., piping to
7187
// `stamp` in the rust CI).
72-
let out = format!(" {}/{}\n", self.test_count + 1, self.total_test_count);
73-
self.write_plain(out)?;
88+
self.write_progress()?;
7489
}
7590

76-
self.test_count += 1;
91+
Ok(())
92+
}
93+
94+
fn write_progress(&mut self) -> io::Result<()> {
95+
let out = format!(" {}/{}\n", self.test_count, self.total_test_count);
96+
self.write_plain(out)?;
97+
self.test_column = 0;
7798
Ok(())
7899
}
79100

@@ -213,7 +234,7 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
213234
match *result {
214235
TestResult::TrOk => self.write_ok(),
215236
TestResult::TrFailed | TestResult::TrFailedMsg(_) | TestResult::TrTimedFail => {
216-
self.write_failed()
237+
self.write_failed(desc.name.as_slice())
217238
}
218239
TestResult::TrIgnored => self.write_ignored(),
219240
TestResult::TrBench(ref bs) => {

0 commit comments

Comments
 (0)