@@ -213,7 +213,7 @@ fn remove_and_create_dir_all(path: &Path) {
213213 fs:: create_dir_all ( path) . unwrap ( ) ;
214214}
215215
216- #[ derive( Copy , Clone ) ]
216+ #[ derive( Copy , Clone , Debug ) ]
217217struct TestCx < ' test > {
218218 config : & ' test Config ,
219219 props : & ' test TestProps ,
@@ -2579,6 +2579,13 @@ impl<'test> TestCx<'test> {
25792579 actual_unnormalized : & str ,
25802580 expected : & str ,
25812581 ) -> bool {
2582+ let expected_path =
2583+ expected_output_path ( self . testpaths , self . revision , & self . config . compare_mode , stream) ;
2584+
2585+ if self . config . bless && actual. is_empty ( ) && expected_path. exists ( ) {
2586+ self . delete_file ( & expected_path) ;
2587+ }
2588+
25822589 let are_different = match ( self . force_color_svg ( ) , expected. find ( '\n' ) , actual. find ( '\n' ) ) {
25832590 // FIXME: We ignore the first line of SVG files
25842591 // because the width parameter is non-deterministic.
@@ -2628,9 +2635,6 @@ impl<'test> TestCx<'test> {
26282635 }
26292636 println ! ( "Saved the actual {stream} to {actual_path:?}" ) ;
26302637
2631- let expected_path =
2632- expected_output_path ( self . testpaths , self . revision , & self . config . compare_mode , stream) ;
2633-
26342638 if !self . config . bless {
26352639 if expected. is_empty ( ) {
26362640 println ! ( "normalized {}:\n {}\n " , stream, actual) ;
@@ -2653,10 +2657,12 @@ impl<'test> TestCx<'test> {
26532657 self . delete_file ( & old) ;
26542658 }
26552659
2656- if let Err ( err) = fs:: write ( & expected_path, & actual) {
2657- self . fatal ( & format ! ( "failed to write {stream} to `{expected_path:?}`: {err}" ) ) ;
2660+ if !actual. is_empty ( ) {
2661+ if let Err ( err) = fs:: write ( & expected_path, & actual) {
2662+ self . fatal ( & format ! ( "failed to write {stream} to `{expected_path:?}`: {err}" ) ) ;
2663+ }
2664+ println ! ( "Blessing the {stream} of {test_name} in {expected_path:?}" ) ;
26582665 }
2659- println ! ( "Blessing the {stream} of {test_name} in {expected_path:?}" ) ;
26602666 }
26612667
26622668 println ! ( "\n The actual {0} differed from the expected {0}." , stream) ;
0 commit comments