Skip to content

Commit e166e61

Browse files
Rollup merge of rust-lang#53428 - RalfJung:libtest-terse, r=KodrAus
libtest terse format: show how far in we are So for example `./x.py test src/libcore` looks like ``` running 881 tests .................................................................................................... 100/881 .................................................................................................... 200/881 .................................................................................................... 300/881 .............................................................i.i.................................... 400/881 .................................................................................................... 500/881 .................................................................................................... 600/881 .................................................................................................... 700/881 .................................................................................................... 800/881 ................................................................................. test result: ok. 879 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out ``` When I am waiting for 3500 ui tests to complete, I am often missing some sense of how far in these 3500 it is. Getting the total count in `write_run_start` is a bit hacky; I did that to not change the "public interface" of the formatters. I can also give them an extra argument in their constructor so that they know from the beginning how many tests there will be. Would you prefer that? (I think I would, but I wanted to get feedback first.)
2 parents 49944ae + ffbb407 commit e166e61

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libtest/formatters/terse.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub(crate) struct TerseFormatter<T> {
1818
max_name_len: usize,
1919

2020
test_count: usize,
21+
total_test_count: usize,
2122
}
2223

2324
impl<T: Write> TerseFormatter<T> {
@@ -33,6 +34,7 @@ impl<T: Write> TerseFormatter<T> {
3334
max_name_len,
3435
is_multithreaded,
3536
test_count: 0,
37+
total_test_count: 0, // initialized later, when write_run_start is called
3638
}
3739
}
3840

@@ -66,7 +68,8 @@ impl<T: Write> TerseFormatter<T> {
6668
// we insert a new line every 100 dots in order to flush the
6769
// screen when dealing with line-buffered output (e.g. piping to
6870
// `stamp` in the rust CI).
69-
self.write_plain("\n")?;
71+
let out = format!(" {}/{}\n", self.test_count+1, self.total_test_count);
72+
self.write_plain(&out)?;
7073
}
7174

7275
self.test_count += 1;
@@ -160,6 +163,7 @@ impl<T: Write> TerseFormatter<T> {
160163

161164
impl<T: Write> OutputFormatter for TerseFormatter<T> {
162165
fn write_run_start(&mut self, test_count: usize) -> io::Result<()> {
166+
self.total_test_count = test_count;
163167
let noun = if test_count != 1 { "tests" } else { "test" };
164168
self.write_plain(&format!("\nrunning {} {}\n", test_count, noun))
165169
}

0 commit comments

Comments
 (0)