@@ -281,23 +281,15 @@ fn on_test_event(
281281 Ok ( ( ) )
282282}
283283
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 > {
287285 let output = match term:: stdout ( ) {
288286 None => OutputLocation :: Raw ( io:: stdout ( ) ) ,
289287 Some ( t) => OutputLocation :: Pretty ( t) ,
290288 } ;
291289
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-
298290 let is_multithreaded = opts. test_threads . unwrap_or_else ( get_concurrency) > 1 ;
299291
300- let mut out : Box < dyn OutputFormatter > = match opts. format {
292+ match opts. format {
301293 OutputFormat :: Pretty => Box :: new ( PrettyFormatter :: new (
302294 output,
303295 opts. use_color ( ) ,
@@ -310,7 +302,19 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
310302 }
311303 OutputFormat :: Json => Box :: new ( JsonFormatter :: new ( output) ) ,
312304 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) ;
314318 let mut st = ConsoleTestState :: new ( opts) ?;
315319
316320 // Prevent the usage of `Instant` in some cases:
0 commit comments