@@ -60,27 +60,43 @@ impl Runner {
6060 snapbox:: debug!( "Case: {:#?}" , s) ;
6161 match s {
6262 Ok ( status) => {
63- let _ = writeln ! (
63+ let _ = write ! (
6464 stderr,
6565 "{} {} ... {}" ,
6666 palette. hint( "Testing" ) ,
6767 status. name( ) ,
68- status. spawn. status. summary( )
68+ status. spawn. status. summary( ) ,
6969 ) ;
70+ if let Some ( duration) = status. duration {
71+ let _ = write ! (
72+ stderr,
73+ " {}" ,
74+ palette. hint( humantime:: format_duration( duration) ) ,
75+ ) ;
76+ }
77+ let _ = writeln ! ( stderr) ;
7078 if !status. is_ok ( ) {
7179 // Assuming `status` will print the newline
7280 let _ = write ! ( stderr, "{}" , & status) ;
7381 }
7482 None
7583 }
7684 Err ( status) => {
77- let _ = writeln ! (
85+ let _ = write ! (
7886 stderr,
7987 "{} {} ... {}" ,
8088 palette. hint( "Testing" ) ,
8189 status. name( ) ,
8290 palette. error( "failed" ) ,
8391 ) ;
92+ if let Some ( duration) = status. duration {
93+ let _ = write ! (
94+ stderr,
95+ " {}" ,
96+ palette. hint( humantime:: format_duration( duration) ) ,
97+ ) ;
98+ }
99+ let _ = writeln ! ( stderr) ;
84100 // Assuming `status` will print the newline
85101 let _ = write ! ( stderr, "{}" , & status) ;
86102 Some ( status)
@@ -356,10 +372,13 @@ impl Case {
356372 }
357373
358374 let cmd = step. to_command ( cwd) . map_err ( |e| output. clone ( ) . error ( e) ) ?;
375+ let timer = std:: time:: Instant :: now ( ) ;
359376 let cmd_output = cmd
360377 . output ( )
361378 . map_err ( |e| output. clone ( ) . error ( e. to_string ( ) . into ( ) ) ) ?;
379+
362380 let output = output. output ( cmd_output) ;
381+ let output = output. duration ( timer. elapsed ( ) ) ;
363382
364383 // For Mode::Dump's sake, allow running all
365384 let output = self . validate_spawn ( output, step. expected_status ( ) ) ;
@@ -549,6 +568,7 @@ pub(crate) struct Output {
549568 stdout : Option < Stream > ,
550569 stderr : Option < Stream > ,
551570 fs : Filesystem ,
571+ duration : Option < std:: time:: Duration > ,
552572}
553573
554574impl Output {
@@ -563,6 +583,7 @@ impl Output {
563583 stdout : None ,
564584 stderr : None ,
565585 fs : Default :: default ( ) ,
586+ duration : Default :: default ( ) ,
566587 }
567588 }
568589
@@ -574,6 +595,7 @@ impl Output {
574595 stdout : None ,
575596 stderr : None ,
576597 fs : Default :: default ( ) ,
598+ duration : Default :: default ( ) ,
577599 }
578600 }
579601
@@ -599,6 +621,11 @@ impl Output {
599621 self
600622 }
601623
624+ fn duration ( mut self , duration : std:: time:: Duration ) -> Self {
625+ self . duration = Some ( duration) ;
626+ self
627+ }
628+
602629 fn is_ok ( & self ) -> bool {
603630 self . spawn . is_ok ( )
604631 && self . stdout . as_ref ( ) . map ( |s| s. is_ok ( ) ) . unwrap_or ( true )
0 commit comments