@@ -5,6 +5,7 @@ use anstream::{eprint as print, eprintln as println};
5
5
use clap:: Args ;
6
6
use color_print:: { cprint, cprintln} ;
7
7
use glob:: glob;
8
+ use similar:: { ChangeTag , TextDiff } ;
8
9
use which:: which;
9
10
10
11
use crate :: manifest:: Manifest ;
@@ -211,8 +212,21 @@ fn bless(update: bool, case: &TestCase) {
211
212
if update {
212
213
std:: fs:: copy ( output, blessed) . unwrap ( ) ;
213
214
} else {
214
- let output = std:: fs:: read ( output) . unwrap ( ) ;
215
- let blessed = std:: fs:: read ( blessed) . unwrap ( ) ;
216
- assert_eq ! ( output, blessed, "output does not match blessed output" ) ;
215
+ let output = std:: fs:: read_to_string ( output) . unwrap ( ) ;
216
+ let blessed = std:: fs:: read_to_string ( blessed) . unwrap ( ) ;
217
+
218
+ let diff = TextDiff :: from_lines ( & blessed, & output) ;
219
+ if diff. ratio ( ) < 1.0 {
220
+ cprintln ! ( "<r,s>output does not match blessed output</r,s>" ) ;
221
+ for change in diff. iter_all_changes ( ) {
222
+ let lineno = change. old_index ( ) . unwrap_or ( change. new_index ( ) . unwrap_or ( 0 ) ) ;
223
+ match change. tag ( ) {
224
+ ChangeTag :: Equal => print ! ( " {:4}| {}" , lineno, change) ,
225
+ ChangeTag :: Insert => cprint ! ( "<g>+{:4}| {}</g>" , lineno, change) ,
226
+ ChangeTag :: Delete => cprint ! ( "<r>-{:4}| {}</r>" , lineno, change) ,
227
+ }
228
+ }
229
+ std:: process:: exit ( 1 ) ;
230
+ }
217
231
}
218
232
}
0 commit comments