@@ -991,6 +991,7 @@ pub mod test {
991991 use std:: path:: PathBuf ;
992992 use std:: process;
993993 use std:: sync:: { Arc , Mutex } ;
994+ use std:: fmt;
994995
995996 #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq , Clone ) ]
996997 pub struct Test {
@@ -1106,7 +1107,7 @@ pub mod test {
11061107 }
11071108 }
11081109
1109- #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
1110+ #[ derive( PartialEq , Eq ) ]
11101111 pub struct TestFailure {
11111112 /// The test case, indicating file, line, and column
11121113 pub test : Test ,
@@ -1123,6 +1124,23 @@ pub mod test {
11231124 pub actual_data : Result < Result < Vec < MarkedString > , String > , ( ) > ,
11241125 }
11251126
1127+ impl fmt:: Debug for TestFailure {
1128+ fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1129+ fmt. debug_struct ( "TestFailure" )
1130+ . field ( "test" , & self . test )
1131+ . field ( "expect_file" , & self . expect_file )
1132+ . field ( "actual_file" , & self . actual_file )
1133+ . field ( "expect_data" , & self . expect_data )
1134+ . field ( "actual_data" , & self . actual_data )
1135+ . finish ( ) ?;
1136+
1137+ let expected = format ! ( "{:#?}" , self . expect_data) ;
1138+ let actual = format ! ( "{:#?}" , self . actual_data) ;
1139+ write ! ( fmt, "-diff: {}" , difference:: Changeset :: new( & expected, & actual, "" ) )
1140+ }
1141+ }
1142+
1143+
11261144 #[ derive( Clone , Default ) ]
11271145 pub struct LineOutput {
11281146 req_id : Arc < Mutex < u64 > > ,
@@ -2117,7 +2135,7 @@ pub mod test {
21172135 Ok ( ( ) )
21182136 } else {
21192137 eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2120- eprintln ! ( "{:#?}\n \n " , failures) ;
2138+ eprintln ! ( "Failures ( \x1b [91mexpected \x1b [92mactual \x1b [0m): {:#?}\n \n " , failures) ;
21212139 Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
21222140 }
21232141 }
@@ -2172,7 +2190,7 @@ pub mod test {
21722190 Ok ( ( ) )
21732191 } else {
21742192 eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2175- eprintln ! ( "{:#?}\n \n " , failures) ;
2193+ eprintln ! ( "Failures ( \x1b [91mexpected \x1b [92mactual \x1b [0m): {:#?}\n \n " , failures) ;
21762194 Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
21772195 }
21782196 }
0 commit comments