@@ -213,7 +213,7 @@ fn remove_and_create_dir_all(path: &Path) {
213
213
fs:: create_dir_all ( path) . unwrap ( ) ;
214
214
}
215
215
216
- #[ derive( Copy , Clone ) ]
216
+ #[ derive( Copy , Clone , Debug ) ]
217
217
struct TestCx < ' test > {
218
218
config : & ' test Config ,
219
219
props : & ' test TestProps ,
@@ -2589,7 +2589,14 @@ impl<'test> TestCx<'test> {
2589
2589
actual : & str ,
2590
2590
actual_unnormalized : & str ,
2591
2591
expected : & str ,
2592
- ) -> bool {
2592
+ ) -> CompareOutcome {
2593
+ let expected_path =
2594
+ expected_output_path ( self . testpaths , self . revision , & self . config . compare_mode , stream) ;
2595
+
2596
+ if self . config . bless && actual. is_empty ( ) && expected_path. exists ( ) {
2597
+ self . delete_file ( & expected_path) ;
2598
+ }
2599
+
2593
2600
let are_different = match ( self . force_color_svg ( ) , expected. find ( '\n' ) , actual. find ( '\n' ) ) {
2594
2601
// FIXME: We ignore the first line of SVG files
2595
2602
// because the width parameter is non-deterministic.
@@ -2639,9 +2646,6 @@ impl<'test> TestCx<'test> {
2639
2646
}
2640
2647
println ! ( "Saved the actual {stream} to {actual_path:?}" ) ;
2641
2648
2642
- let expected_path =
2643
- expected_output_path ( self . testpaths , self . revision , & self . config . compare_mode , stream) ;
2644
-
2645
2649
if !self . config . bless {
2646
2650
if expected. is_empty ( ) {
2647
2651
println ! ( "normalized {}:\n {}\n " , stream, actual) ;
@@ -2664,10 +2668,12 @@ impl<'test> TestCx<'test> {
2664
2668
self . delete_file ( & old) ;
2665
2669
}
2666
2670
2667
- if let Err ( err) = fs:: write ( & expected_path, & actual) {
2668
- self . fatal ( & format ! ( "failed to write {stream} to `{expected_path:?}`: {err}" ) ) ;
2671
+ if !actual. is_empty ( ) {
2672
+ if let Err ( err) = fs:: write ( & expected_path, & actual) {
2673
+ self . fatal ( & format ! ( "failed to write {stream} to `{expected_path:?}`: {err}" ) ) ;
2674
+ }
2675
+ println ! ( "Blessing the {stream} of {test_name} in {expected_path:?}" ) ;
2669
2676
}
2670
- println ! ( "Blessing the {stream} of {test_name} in {expected_path:?}" ) ;
2671
2677
}
2672
2678
2673
2679
println ! ( "\n The actual {0} differed from the expected {0}." , stream) ;
0 commit comments