@@ -46,6 +46,8 @@ pub struct Config {
4646 /// Can be used to override what command to run instead of `cargo` to build the
4747 /// dependencies in `manifest_path`
4848 pub dependency_builder : Option < DependencyBuilder > ,
49+ /// Print one character per test instead of one line
50+ pub quiet : bool ,
4951}
5052
5153#[ derive( Debug ) ]
@@ -125,10 +127,38 @@ pub fn run_tests(mut config: Config) -> Result<()> {
125127
126128 // A channel for the messages emitted by the individual test threads.
127129 let ( finish_file, finished_files) = crossbeam:: channel:: unbounded ( ) ;
130+ enum TestResult {
131+ Ok ,
132+ Failed ,
133+ Ignored ,
134+ }
128135
129136 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+ }
132162 }
133163 } ) ;
134164
@@ -151,12 +181,7 @@ pub fn run_tests(mut config: Config) -> Result<()> {
151181 // Ignore file if only/ignore rules do (not) apply
152182 if !test_file_conditions ( & comments, & target, & config) {
153183 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 ) ) ?;
160185 continue ;
161186 }
162187 // Run the test for all revisions
@@ -171,12 +196,11 @@ pub fn run_tests(mut config: Config) -> Result<()> {
171196 if !revision. is_empty ( ) {
172197 write ! ( msg, "(revision `{revision}`) " ) . unwrap ( ) ;
173198 }
174- write ! ( msg, "... " ) . unwrap ( ) ;
175199 if errors. is_empty ( ) {
176- write ! ( msg, "{}" , "ok" . green ( ) ) . unwrap ( ) ;
200+ finish_file . send ( ( msg, TestResult :: Ok ) ) ? ;
177201 succeeded. fetch_add ( 1 , Ordering :: Relaxed ) ;
178202 } else {
179- write ! ( msg, "{}" , "FAILED" . red ( ) . bold ( ) ) . unwrap ( ) ;
203+ finish_file . send ( ( msg, TestResult :: Failed ) ) ? ;
180204 failures. lock ( ) . unwrap ( ) . push ( (
181205 path. clone ( ) ,
182206 m,
@@ -185,7 +209,6 @@ pub fn run_tests(mut config: Config) -> Result<()> {
185209 stderr,
186210 ) ) ;
187211 }
188- finish_file. send ( msg) ?;
189212 }
190213 }
191214 Ok ( ( ) )
0 commit comments