@@ -46,6 +46,8 @@ pub struct Config {
46
46
/// Can be used to override what command to run instead of `cargo` to build the
47
47
/// dependencies in `manifest_path`
48
48
pub dependency_builder : Option < DependencyBuilder > ,
49
+ /// Print one character per test instead of one line
50
+ pub quiet : bool ,
49
51
}
50
52
51
53
#[ derive( Debug ) ]
@@ -125,10 +127,38 @@ pub fn run_tests(mut config: Config) -> Result<()> {
125
127
126
128
// A channel for the messages emitted by the individual test threads.
127
129
let ( finish_file, finished_files) = crossbeam:: channel:: unbounded ( ) ;
130
+ enum TestResult {
131
+ Ok ,
132
+ Failed ,
133
+ Ignored ,
134
+ }
128
135
129
136
s. spawn ( |_| {
130
- for msg in finished_files {
131
- eprintln ! ( "{msg}" ) ;
137
+ if config. quiet {
138
+ for ( i, ( _, result) ) in finished_files. into_iter ( ) . enumerate ( ) {
139
+ // Humans start counting at 1
140
+ let i = i + 1 ;
141
+ match result {
142
+ TestResult :: Ok => eprint ! ( "{}" , "." . green( ) ) ,
143
+ TestResult :: Failed => eprint ! ( "{}" , "F" . red( ) . bold( ) ) ,
144
+ TestResult :: Ignored => eprint ! ( "{}" , "i" . yellow( ) ) ,
145
+ }
146
+ if i % 100 == 0 {
147
+ eprintln ! ( " {i}" ) ;
148
+ }
149
+ }
150
+ } else {
151
+ for ( msg, result) in finished_files {
152
+ eprint ! ( "{msg} ... " ) ;
153
+ eprintln ! (
154
+ "{}" ,
155
+ match result {
156
+ TestResult :: Ok => "ok" . green( ) ,
157
+ TestResult :: Failed => "FAILED" . red( ) . bold( ) ,
158
+ TestResult :: Ignored => "ignored (in-test comment)" . yellow( ) ,
159
+ }
160
+ ) ;
161
+ }
132
162
}
133
163
} ) ;
134
164
@@ -151,12 +181,7 @@ pub fn run_tests(mut config: Config) -> Result<()> {
151
181
// Ignore file if only/ignore rules do (not) apply
152
182
if !test_file_conditions ( & comments, & target, & config) {
153
183
ignored. fetch_add ( 1 , Ordering :: Relaxed ) ;
154
- let msg = format ! (
155
- "{} ... {}" ,
156
- path. display( ) ,
157
- "ignored (in-test comment)" . yellow( )
158
- ) ;
159
- finish_file. send ( msg) ?;
184
+ finish_file. send ( ( path. display ( ) . to_string ( ) , TestResult :: Ignored ) ) ?;
160
185
continue ;
161
186
}
162
187
// Run the test for all revisions
@@ -171,12 +196,11 @@ pub fn run_tests(mut config: Config) -> Result<()> {
171
196
if !revision. is_empty ( ) {
172
197
write ! ( msg, "(revision `{revision}`) " ) . unwrap ( ) ;
173
198
}
174
- write ! ( msg, "... " ) . unwrap ( ) ;
175
199
if errors. is_empty ( ) {
176
- write ! ( msg, "{}" , "ok" . green ( ) ) . unwrap ( ) ;
200
+ finish_file . send ( ( msg, TestResult :: Ok ) ) ? ;
177
201
succeeded. fetch_add ( 1 , Ordering :: Relaxed ) ;
178
202
} else {
179
- write ! ( msg, "{}" , "FAILED" . red ( ) . bold ( ) ) . unwrap ( ) ;
203
+ finish_file . send ( ( msg, TestResult :: Failed ) ) ? ;
180
204
failures. lock ( ) . unwrap ( ) . push ( (
181
205
path. clone ( ) ,
182
206
m,
@@ -185,7 +209,6 @@ pub fn run_tests(mut config: Config) -> Result<()> {
185
209
stderr,
186
210
) ) ;
187
211
}
188
- finish_file. send ( msg) ?;
189
212
}
190
213
}
191
214
Ok ( ( ) )
0 commit comments