@@ -38,6 +38,8 @@ pub struct Config {
3838 pub output_conflict_handling : OutputConflictHandling ,
3939 /// Only run tests with one of these strings in their path/name
4040 pub path_filter : Vec < String > ,
41+ /// Print one character per test instead of one line
42+ pub quiet : bool ,
4143}
4244
4345#[ derive( Debug ) ]
@@ -96,10 +98,38 @@ pub fn run_tests(config: Config) -> Result<()> {
9698
9799 // A channel for the messages emitted by the individual test threads.
98100 let ( finish_file, finished_files) = crossbeam:: channel:: unbounded ( ) ;
101+ enum TestResult {
102+ Ok ,
103+ Failed ,
104+ Ignored ,
105+ }
99106
100107 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+ }
103133 }
104134 } ) ;
105135
@@ -122,12 +152,7 @@ pub fn run_tests(config: Config) -> Result<()> {
122152 // Ignore file if only/ignore rules do (not) apply
123153 if !test_file_conditions ( & comments, & target, & config) {
124154 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 ) ) ?;
131156 continue ;
132157 }
133158 // Run the test for all revisions
@@ -142,12 +167,11 @@ pub fn run_tests(config: Config) -> Result<()> {
142167 if !revision. is_empty ( ) {
143168 write ! ( msg, "(revision `{revision}`) " ) . unwrap ( ) ;
144169 }
145- write ! ( msg, "... " ) . unwrap ( ) ;
146170 if errors. is_empty ( ) {
147- write ! ( msg, "{}" , "ok" . green ( ) ) . unwrap ( ) ;
171+ finish_file . send ( ( msg, TestResult :: Ok ) ) ? ;
148172 succeeded. fetch_add ( 1 , Ordering :: Relaxed ) ;
149173 } else {
150- write ! ( msg, "{}" , "FAILED" . red ( ) . bold ( ) ) . unwrap ( ) ;
174+ finish_file . send ( ( msg, TestResult :: Failed ) ) ? ;
151175 failures. lock ( ) . unwrap ( ) . push ( (
152176 path. clone ( ) ,
153177 m,
@@ -156,7 +180,6 @@ pub fn run_tests(config: Config) -> Result<()> {
156180 stderr,
157181 ) ) ;
158182 }
159- finish_file. send ( msg) ?;
160183 }
161184 }
162185 Ok ( ( ) )
0 commit comments