@@ -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 ,
@@ -2589,7 +2589,14 @@ impl<'test> TestCx<'test> {
25892589 actual : & str ,
25902590 actual_unnormalized : & str ,
25912591 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+
25932600 let are_different = match ( self . force_color_svg ( ) , expected. find ( '\n' ) , actual. find ( '\n' ) ) {
25942601 // FIXME: We ignore the first line of SVG files
25952602 // because the width parameter is non-deterministic.
@@ -2639,9 +2646,6 @@ impl<'test> TestCx<'test> {
26392646 }
26402647 println ! ( "Saved the actual {stream} to {actual_path:?}" ) ;
26412648
2642- let expected_path =
2643- expected_output_path ( self . testpaths , self . revision , & self . config . compare_mode , stream) ;
2644-
26452649 if !self . config . bless {
26462650 if expected. is_empty ( ) {
26472651 println ! ( "normalized {}:\n {}\n " , stream, actual) ;
@@ -2664,10 +2668,12 @@ impl<'test> TestCx<'test> {
26642668 self . delete_file ( & old) ;
26652669 }
26662670
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:?}" ) ;
26692676 }
2670- println ! ( "Blessing the {stream} of {test_name} in {expected_path:?}" ) ;
26712677 }
26722678
26732679 println ! ( "\n The actual {0} differed from the expected {0}." , stream) ;
0 commit comments