@@ -38,6 +38,8 @@ pub struct Config {
38
38
pub output_conflict_handling : OutputConflictHandling ,
39
39
/// Only run tests with one of these strings in their path/name
40
40
pub path_filter : Vec < String > ,
41
+ /// Print one character per test instead of one line
42
+ pub quiet : bool ,
41
43
}
42
44
43
45
#[ derive( Debug ) ]
@@ -96,10 +98,38 @@ pub fn run_tests(config: Config) -> Result<()> {
96
98
97
99
// A channel for the messages emitted by the individual test threads.
98
100
let ( finish_file, finished_files) = crossbeam:: channel:: unbounded ( ) ;
101
+ enum TestResult {
102
+ Ok ,
103
+ Failed ,
104
+ Ignored ,
105
+ }
99
106
100
107
s. spawn ( |_| {
101
- for msg in finished_files {
102
- eprintln ! ( "{msg}" ) ;
108
+ if config. quiet {
109
+ for ( i, ( _, result) ) in finished_files. into_iter ( ) . enumerate ( ) {
110
+ // Humans start counting at 1
111
+ let i = i + 1 ;
112
+ match result {
113
+ TestResult :: Ok => eprint ! ( "{}" , "." . green( ) ) ,
114
+ TestResult :: Failed => eprint ! ( "{}" , "F" . red( ) . bold( ) ) ,
115
+ TestResult :: Ignored => eprint ! ( "{}" , "i" . yellow( ) ) ,
116
+ }
117
+ if i % 100 == 0 {
118
+ eprintln ! ( " {i}" ) ;
119
+ }
120
+ }
121
+ } else {
122
+ for ( msg, result) in finished_files {
123
+ eprint ! ( "{msg} ... " ) ;
124
+ eprintln ! (
125
+ "{}" ,
126
+ match result {
127
+ TestResult :: Ok => "ok" . green( ) ,
128
+ TestResult :: Failed => "FAILED" . red( ) . bold( ) ,
129
+ TestResult :: Ignored => "ignored (in-test comment)" . yellow( ) ,
130
+ }
131
+ ) ;
132
+ }
103
133
}
104
134
} ) ;
105
135
@@ -122,12 +152,7 @@ pub fn run_tests(config: Config) -> Result<()> {
122
152
// Ignore file if only/ignore rules do (not) apply
123
153
if !test_file_conditions ( & comments, & target, & config) {
124
154
ignored. fetch_add ( 1 , Ordering :: Relaxed ) ;
125
- let msg = format ! (
126
- "{} ... {}" ,
127
- path. display( ) ,
128
- "ignored (in-test comment)" . yellow( )
129
- ) ;
130
- finish_file. send ( msg) ?;
155
+ finish_file. send ( ( path. display ( ) . to_string ( ) , TestResult :: Ignored ) ) ?;
131
156
continue ;
132
157
}
133
158
// Run the test for all revisions
@@ -142,12 +167,11 @@ pub fn run_tests(config: Config) -> Result<()> {
142
167
if !revision. is_empty ( ) {
143
168
write ! ( msg, "(revision `{revision}`) " ) . unwrap ( ) ;
144
169
}
145
- write ! ( msg, "... " ) . unwrap ( ) ;
146
170
if errors. is_empty ( ) {
147
- write ! ( msg, "{}" , "ok" . green ( ) ) . unwrap ( ) ;
171
+ finish_file . send ( ( msg, TestResult :: Ok ) ) ? ;
148
172
succeeded. fetch_add ( 1 , Ordering :: Relaxed ) ;
149
173
} else {
150
- write ! ( msg, "{}" , "FAILED" . red ( ) . bold ( ) ) . unwrap ( ) ;
174
+ finish_file . send ( ( msg, TestResult :: Failed ) ) ? ;
151
175
failures. lock ( ) . unwrap ( ) . push ( (
152
176
path. clone ( ) ,
153
177
m,
@@ -156,7 +180,6 @@ pub fn run_tests(config: Config) -> Result<()> {
156
180
stderr,
157
181
) ) ;
158
182
}
159
- finish_file. send ( msg) ?;
160
183
}
161
184
}
162
185
Ok ( ( ) )
0 commit comments