@@ -156,6 +156,7 @@ pub async fn run_tests(
156156 // Collect parse errors and valid files
157157 let mut valid_files = Vec :: new ( ) ;
158158 let mut parse_error_count = 0 ;
159+ let mut total_assertions_count = 0 ;
159160
160161 for result in parse_results {
161162 match result {
@@ -180,6 +181,11 @@ pub async fn run_tests(
180181 ) ) ;
181182 }
182183 }
184+
185+ // Count assertions in this file
186+ let file_assertions = count_assertions ( & parsed_file. nodes ) ;
187+ total_assertions_count += file_assertions;
188+
183189 valid_files. push ( ( file, parsed_file. nodes ) ) ;
184190 }
185191 ParseResult :: Failure { errors, warnings } => {
@@ -202,6 +208,11 @@ pub async fn run_tests(
202208 }
203209 }
204210
211+ // Print header
212+ if !is_json && !valid_files. is_empty ( ) {
213+ TextFormatter :: print_header ( valid_files. len ( ) , total_assertions_count) ;
214+ }
215+
205216 // Run each file sequentially
206217 let mut file_results = Vec :: new ( ) ;
207218
@@ -246,11 +257,8 @@ pub async fn run_tests(
246257 println ! ( "{}" , formatter. format( & output) ) ;
247258 }
248259 OutputFormat :: Text => {
249- let formatter = TextFormatter {
250- verbose : options. verbose ,
251- } ;
252260 println ! ( ) ;
253- println ! ( "{}" , formatter . format( & output) ) ;
261+ println ! ( "{}" , TextFormatter . format( & output) ) ;
254262 }
255263 }
256264
@@ -306,18 +314,18 @@ async fn run_file(
306314 reporter : & impl Reporter ,
307315) -> anyhow:: Result < FileRunResult > {
308316 let is_json = options. output_format == OutputFormat :: Json ;
317+ let file_start = std:: time:: Instant :: now ( ) ;
309318 let cwd = Path :: new ( filename)
310319 . parent ( )
311320 . unwrap_or ( Path :: new ( "." ) )
312321 . to_string_lossy ( )
313- . to_string ( ) ;
322+ . into_owned ( ) ;
314323
315324 let basename = Path :: new ( filename)
316325 . file_name ( )
317326 . unwrap_or_default ( )
318- . to_string_lossy ( ) ;
319-
320- reporter. on_file_start ( & basename) ;
327+ . to_string_lossy ( )
328+ . into_owned ( ) ;
321329
322330 // Extract pragmas
323331 let pragmas: Vec < _ > = ast
@@ -400,9 +408,7 @@ async fn run_file(
400408 }
401409 }
402410
403- if !is_json {
404- println ! ( ) ; // Newline after progress dots
405- }
411+ let file_duration_ms = file_start. elapsed ( ) . as_millis ( ) as u64 ;
406412
407413 let file_result = FileResult {
408414 file : filename. to_string ( ) ,
@@ -413,18 +419,11 @@ async fn run_file(
413419 if let Some ( ref f) = failure {
414420 reporter. on_failure ( f) ;
415421 } else if !is_json {
416- let assertions_text = if total_assertions_passed == 1 {
417- "assertion"
418- } else {
419- "assertions"
420- } ;
421-
422- use owo_colors:: OwoColorize ;
423- println ! (
424- "PASS {} ({} {})" ,
425- basename,
422+ TextFormatter :: print_file_result (
423+ & basename,
424+ true ,
426425 total_assertions_passed,
427- assertions_text . green ( )
426+ file_duration_ms ,
428427 ) ;
429428 }
430429
@@ -458,11 +457,18 @@ fn group_nodes_by_test(nodes: &[ASTNode]) -> Vec<TestBlock> {
458457 blocks
459458}
460459
460+ fn count_assertions ( nodes : & [ ASTNode ] ) -> usize {
461+ nodes
462+ . iter ( )
463+ . filter ( |node| matches ! ( node, ASTNode :: Assert ( _) ) )
464+ . count ( )
465+ }
466+
461467async fn execute_test_block (
462468 block : & TestBlock ,
463469 session : & mut ShellSession ,
464470 filename : & str ,
465- reporter : & impl Reporter ,
471+ _reporter : & impl Reporter ,
466472) -> ExecuteResult {
467473 let test_start = std:: time:: Instant :: now ( ) ;
468474
@@ -543,16 +549,13 @@ async fn execute_test_block(
543549 . await
544550 {
545551 Ok ( result) => {
546- reporter. on_run_complete ( & result. run_id , true ) ;
547552 if let Some ( ref name) = run_node. name {
548553 run_results. insert ( name. clone ( ) , result. clone ( ) ) ;
549554 }
550555 last_run_result = Some ( result) ;
551556 last_run_node = Some ( run_node) ;
552557 }
553558 Err ( e) => {
554- reporter. on_run_complete ( "" , false ) ;
555-
556559 // Add the failed run
557560 command_runs. push ( CommandRun {
558561 name : run_node. name . clone ( ) ,
@@ -664,7 +667,6 @@ async fn execute_test_block(
664667 }
665668
666669 assertions_passed += 1 ;
667- reporter. on_assertion_pass ( ) ;
668670 }
669671
670672 _ => { }
0 commit comments