@@ -23,6 +23,7 @@ pub(crate) struct TerseFormatter<T> {
23
23
max_name_len : usize ,
24
24
25
25
test_count : usize ,
26
+ test_column : usize ,
26
27
total_test_count : usize ,
27
28
}
28
29
@@ -39,6 +40,7 @@ impl<T: Write> TerseFormatter<T> {
39
40
max_name_len,
40
41
is_multithreaded,
41
42
test_count : 0 ,
43
+ test_column : 0 ,
42
44
total_test_count : 0 , // initialized later, when write_run_start is called
43
45
}
44
46
}
@@ -47,8 +49,20 @@ impl<T: Write> TerseFormatter<T> {
47
49
self . write_short_result ( "." , term:: color:: GREEN )
48
50
}
49
51
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 " )
52
66
}
53
67
54
68
pub fn write_ignored ( & mut self ) -> io:: Result < ( ) > {
@@ -65,15 +79,22 @@ impl<T: Write> TerseFormatter<T> {
65
79
color : term:: color:: Color ,
66
80
) -> io:: Result < ( ) > {
67
81
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 {
69
85
// We insert a new line regularly in order to flush the
70
86
// screen when dealing with line-buffered output (e.g., piping to
71
87
// `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 ( ) ?;
74
89
}
75
90
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 ;
77
98
Ok ( ( ) )
78
99
}
79
100
@@ -213,7 +234,7 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
213
234
match * result {
214
235
TestResult :: TrOk => self . write_ok ( ) ,
215
236
TestResult :: TrFailed | TestResult :: TrFailedMsg ( _) | TestResult :: TrTimedFail => {
216
- self . write_failed ( )
237
+ self . write_failed ( desc . name . as_slice ( ) )
217
238
}
218
239
TestResult :: TrIgnored => self . write_ignored ( ) ,
219
240
TestResult :: TrBench ( ref bs) => {
0 commit comments