@@ -10,7 +10,6 @@ use anyhow::Context as _;
1010use clap:: ArgEnum ;
1111use clap:: Args ;
1212use clap:: ValueHint ;
13- use colored:: Colorize as _;
1413use stack_graphs:: arena:: Handle ;
1514use stack_graphs:: graph:: File ;
1615use stack_graphs:: graph:: StackGraph ;
@@ -34,6 +33,8 @@ use crate::LoadError;
3433use crate :: NoCancellation ;
3534use crate :: StackGraphLanguage ;
3635
36+ use super :: util:: FileStatusLogger ;
37+
3738/// Flag to control output
3839#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , ArgEnum ) ]
3940pub enum OutputMode {
@@ -206,8 +207,10 @@ impl TestArgs {
206207 test_path : & Path ,
207208 loader : & mut Loader ,
208209 ) -> anyhow:: Result < TestResult > {
210+ let mut file_status = FileStatusLogger :: new ( test_path, !self . quiet ) ;
211+
209212 if self . show_skipped && test_path. extension ( ) . map_or ( false , |e| e == "skip" ) {
210- println ! ( "{}: {}" , test_path . display ( ) , "skipped" . yellow ( ) ) ;
213+ file_status . warn ( "skipped" ) ? ;
211214 return Ok ( TestResult :: new ( ) ) ;
212215 }
213216
@@ -220,9 +223,7 @@ impl TestArgs {
220223 } ;
221224 let source = file_reader. get ( test_path) ?;
222225
223- if !self . quiet {
224- print ! ( "{}: " , test_path. display( ) ) ;
225- }
226+ file_status. processing ( ) ?;
226227
227228 let default_fragment_path = test_path. strip_prefix ( test_root) . unwrap ( ) ;
228229 let mut test = Test :: from_source ( & test_path, & source, default_fragment_path) ?;
@@ -269,7 +270,7 @@ impl TestArgs {
269270 }
270271 }
271272 let result = test. run ( cancellation_flag) ?;
272- let success = self . handle_result ( test_path , & result ) ?;
273+ let success = self . handle_result ( & result , & mut file_status ) ?;
273274 if self . output_mode . test ( !success) {
274275 let files = test. fragments . iter ( ) . map ( |f| f. file ) . collect :: < Vec < _ > > ( ) ;
275276 self . save_output (
@@ -314,25 +315,20 @@ impl TestArgs {
314315 }
315316 }
316317
317- fn handle_result ( & self , test_path : & Path , result : & TestResult ) -> anyhow:: Result < bool > {
318+ fn handle_result (
319+ & self ,
320+ result : & TestResult ,
321+ file_status : & mut FileStatusLogger ,
322+ ) -> anyhow:: Result < bool > {
318323 let success = result. failure_count ( ) == 0 ;
319324 if success {
320- if !self . quiet {
321- println ! ( "{}" , "success" . green( ) ) ;
322- }
325+ file_status. ok ( "success" ) ?;
323326 } else {
324- if self . quiet {
325- print ! ( "{}: " , test_path. display( ) ) ;
326- }
327- println ! (
328- "{}" ,
329- format!(
330- "{}/{} assertions failed" ,
331- result. failure_count( ) ,
332- result. count( ) ,
333- )
334- . red( )
335- ) ;
327+ file_status. error ( & format ! (
328+ "{}/{} assertions failed" ,
329+ result. failure_count( ) ,
330+ result. count( ) ,
331+ ) ) ?;
336332 }
337333 if !success && !self . hide_failure_errors {
338334 for failure in result. failures_iter ( ) {
0 commit comments