@@ -14,6 +14,7 @@ use core::fmt;
1414use forc_pkg:: manifest:: { GenericManifestFile , ManifestFile } ;
1515use forc_pkg:: BuildProfile ;
1616use forc_test:: ecal:: Syscall ;
17+ use forc_tracing:: ansi_output_enabled;
1718use forc_util:: tx_utils:: decode_log_data;
1819use fuel_vm:: fuel_tx;
1920use fuel_vm:: prelude:: * ;
@@ -1512,29 +1513,33 @@ fn print_run_results(
15121513 ) ;
15131514 } else {
15141515 tracing:: info!( "_________________________________" ) ;
1516+ let result_label = if number_of_tests_failed == 0 {
1517+ format_maybe_colored ( "ok" , |txt| txt. green ( ) . bold ( ) )
1518+ } else {
1519+ format_maybe_colored ( "failed" , |txt| txt. red ( ) . bold ( ) )
1520+ } ;
15151521 tracing:: info!(
15161522 "Sway tests result: {}. {} total, {} passed; {} failed; {} disabled [test duration: {}]" ,
1517- if number_of_tests_failed == 0 {
1518- "ok" . green( ) . bold( )
1519- } else {
1520- "failed" . red( ) . bold( )
1521- } ,
1523+ result_label,
15221524 tests_in_run. total_number_of_tests,
15231525 number_of_tests_executed - number_of_tests_failed,
15241526 number_of_tests_failed,
15251527 tests_in_run. disabled_tests. len( ) ,
15261528 util:: duration_to_str( duration) ,
15271529 ) ;
15281530 if number_of_tests_failed > 0 {
1529- tracing:: info!( "{}" , "Failing tests:" . red( ) . bold( ) ) ;
1531+ tracing:: info!(
1532+ "{}" ,
1533+ format_maybe_colored( "Failing tests:" , |txt| txt. red( ) . bold( ) )
1534+ ) ;
15301535 tracing:: info!(
15311536 " {}" ,
15321537 failed_tests
15331538 . iter( )
15341539 . map( |failed_test| format!(
15351540 "{} ... {}" ,
1536- failed_test. bold( ) ,
1537- "failed" . red( ) . bold( )
1541+ format_maybe_colored ( failed_test, |txt| txt . bold( ) ) ,
1542+ format_maybe_colored ( "failed" , |txt| txt . red( ) . bold( ) )
15381543 ) )
15391544 . collect:: <Vec <_>>( )
15401545 . join( "\n " )
@@ -1938,6 +1943,17 @@ fn get_test_abi_from_value(value: &toml::Value) -> Result<BuildTarget> {
19381943 }
19391944}
19401945
1946+ fn format_maybe_colored (
1947+ text : & str ,
1948+ formatter : impl FnOnce ( & str ) -> colored:: ColoredString ,
1949+ ) -> String {
1950+ if ansi_output_enabled ( ) {
1951+ formatter ( text) . to_string ( )
1952+ } else {
1953+ text. to_owned ( )
1954+ }
1955+ }
1956+
19411957fn get_build_profile_from_value ( value : & toml:: Value ) -> Result < & ' static str > {
19421958 match value. as_str ( ) {
19431959 Some ( profile) => match profile {
0 commit comments