@@ -281,23 +281,15 @@ fn on_test_event(
281
281
Ok ( ( ) )
282
282
}
283
283
284
- /// A simple console test runner.
285
- /// Runs provided tests reporting process and results to the stdout.
286
- pub fn run_tests_console ( opts : & TestOpts , tests : Vec < TestDescAndFn > ) -> io:: Result < bool > {
284
+ pub ( crate ) fn get_formatter ( opts : & TestOpts , max_name_len : usize ) -> Box < dyn OutputFormatter > {
287
285
let output = match term:: stdout ( ) {
288
286
None => OutputLocation :: Raw ( io:: stdout ( ) ) ,
289
287
Some ( t) => OutputLocation :: Pretty ( t) ,
290
288
} ;
291
289
292
- let max_name_len = tests
293
- . iter ( )
294
- . max_by_key ( |t| len_if_padded ( t) )
295
- . map ( |t| t. desc . name . as_slice ( ) . len ( ) )
296
- . unwrap_or ( 0 ) ;
297
-
298
290
let is_multithreaded = opts. test_threads . unwrap_or_else ( get_concurrency) > 1 ;
299
291
300
- let mut out : Box < dyn OutputFormatter > = match opts. format {
292
+ match opts. format {
301
293
OutputFormat :: Pretty => Box :: new ( PrettyFormatter :: new (
302
294
output,
303
295
opts. use_color ( ) ,
@@ -310,7 +302,19 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
310
302
}
311
303
OutputFormat :: Json => Box :: new ( JsonFormatter :: new ( output) ) ,
312
304
OutputFormat :: Junit => Box :: new ( JunitFormatter :: new ( output) ) ,
313
- } ;
305
+ }
306
+ }
307
+
308
+ /// A simple console test runner.
309
+ /// Runs provided tests reporting process and results to the stdout.
310
+ pub fn run_tests_console ( opts : & TestOpts , tests : Vec < TestDescAndFn > ) -> io:: Result < bool > {
311
+ let max_name_len = tests
312
+ . iter ( )
313
+ . max_by_key ( |t| len_if_padded ( t) )
314
+ . map ( |t| t. desc . name . as_slice ( ) . len ( ) )
315
+ . unwrap_or ( 0 ) ;
316
+
317
+ let mut out = get_formatter ( opts, max_name_len) ;
314
318
let mut st = ConsoleTestState :: new ( opts) ?;
315
319
316
320
// Prevent the usage of `Instant` in some cases:
0 commit comments