@@ -991,6 +991,7 @@ pub mod test {
991
991
use std:: path:: PathBuf ;
992
992
use std:: process;
993
993
use std:: sync:: { Arc , Mutex } ;
994
+ use std:: fmt;
994
995
995
996
#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq , Clone ) ]
996
997
pub struct Test {
@@ -1106,7 +1107,7 @@ pub mod test {
1106
1107
}
1107
1108
}
1108
1109
1109
- #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
1110
+ #[ derive( PartialEq , Eq ) ]
1110
1111
pub struct TestFailure {
1111
1112
/// The test case, indicating file, line, and column
1112
1113
pub test : Test ,
@@ -1123,6 +1124,23 @@ pub mod test {
1123
1124
pub actual_data : Result < Result < Vec < MarkedString > , String > , ( ) > ,
1124
1125
}
1125
1126
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
+
1126
1144
#[ derive( Clone , Default ) ]
1127
1145
pub struct LineOutput {
1128
1146
req_id : Arc < Mutex < u64 > > ,
@@ -2117,7 +2135,7 @@ pub mod test {
2117
2135
Ok ( ( ) )
2118
2136
} else {
2119
2137
eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2120
- eprintln ! ( "{:#?}\n \n " , failures) ;
2138
+ eprintln ! ( "Failures ( \x1b [91mexpected \x1b [92mactual \x1b [0m): {:#?}\n \n " , failures) ;
2121
2139
Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2122
2140
}
2123
2141
}
@@ -2172,7 +2190,7 @@ pub mod test {
2172
2190
Ok ( ( ) )
2173
2191
} else {
2174
2192
eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2175
- eprintln ! ( "{:#?}\n \n " , failures) ;
2193
+ eprintln ! ( "Failures ( \x1b [91mexpected \x1b [92mactual \x1b [0m): {:#?}\n \n " , failures) ;
2176
2194
Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2177
2195
}
2178
2196
}
0 commit comments