File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed
run-make-support/src/diff Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -3735,15 +3735,14 @@ impl<'test> TestCx<'test> {
37353735 }
37363736
37373737 if self . config . bless {
3738- cmd. env ( "RUSTC_BLESS_TEST" , "--bless" ) ;
3739- // Assume this option is active if the environment variable is "defined", with _any_ value.
3740- // As an example, a `Makefile` can use this option by:
3738+ // If we're running in `--bless` mode, set an environment variable to tell
3739+ // `run_make_support` to bless snapshot files instead of checking them.
37413740 //
3742- // ifdef RUSTC_BLESS_TEST
3743- // cp "$(TMPDIR)"/actual_something.ext expected_something.ext
3744- // else
3745- // $(DIFF) expected_something.ext "$(TMPDIR)"/actual_something.ext
3746- // endif
3741+ // The value is this test's source directory, because the support code
3742+ // will need that path in order to bless the _original_ snapshot files,
3743+ // not the copies in `rmake_out`.
3744+ // (See <https://github.com/rust-lang/rust/issues/129038>.)
3745+ cmd . env ( "RUSTC_BLESS_TEST" , & self . testpaths . file ) ;
37473746 }
37483747
37493748 if self . config . target . contains ( "msvc" ) && !self . config . cc . is_empty ( ) {
Original file line number Diff line number Diff line change @@ -140,16 +140,21 @@ impl Diff {
140140
141141 /// If we have an expected file to write into, and `RUSTC_BLESS_TEST` is
142142 /// set, then write the actual output into the file and return `true`.
143+ ///
144+ /// We assume that `RUSTC_BLESS_TEST` contains the path to the original test's
145+ /// source directory. That lets us bless the original snapshot file in the
146+ /// source tree, not the copy in `rmake_out` that we would normally use.
143147 fn maybe_bless_expected_file ( & self , actual : & str ) -> bool {
144148 let Some ( ref expected_file) = self . expected_file else {
145149 return false ;
146150 } ;
147- if std:: env:: var ( "RUSTC_BLESS_TEST" ) . is_err ( ) {
151+ let Ok ( bless_dir ) = std:: env:: var ( "RUSTC_BLESS_TEST" ) else {
148152 return false ;
149- }
153+ } ;
150154
151- println ! ( "Blessing `{}`" , expected_file. display( ) ) ;
152- fs:: write ( expected_file, actual) ;
155+ let bless_file = Path :: new ( & bless_dir) . join ( expected_file) ;
156+ println ! ( "Blessing `{}`" , bless_file. display( ) ) ;
157+ fs:: write ( bless_file, actual) ;
153158 true
154159 }
155160}
You can’t perform that action at this time.
0 commit comments