Fix blessing of rmake tests
This commit is contained in:
parent
6d91017b02
commit
cc58cf6443
@ -3735,15 +3735,14 @@ fn run_rmake_v2_test(&self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.config.bless {
|
if self.config.bless {
|
||||||
cmd.env("RUSTC_BLESS_TEST", "--bless");
|
// If we're running in `--bless` mode, set an environment variable to tell
|
||||||
// Assume this option is active if the environment variable is "defined", with _any_ value.
|
// `run_make_support` to bless snapshot files instead of checking them.
|
||||||
// As an example, a `Makefile` can use this option by:
|
|
||||||
//
|
//
|
||||||
// ifdef RUSTC_BLESS_TEST
|
// The value is this test's source directory, because the support code
|
||||||
// cp "$(TMPDIR)"/actual_something.ext expected_something.ext
|
// will need that path in order to bless the _original_ snapshot files,
|
||||||
// else
|
// not the copies in `rmake_out`.
|
||||||
// $(DIFF) expected_something.ext "$(TMPDIR)"/actual_something.ext
|
// (See <https://github.com/rust-lang/rust/issues/129038>.)
|
||||||
// endif
|
cmd.env("RUSTC_BLESS_TEST", &self.testpaths.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.config.target.contains("msvc") && !self.config.cc.is_empty() {
|
if self.config.target.contains("msvc") && !self.config.cc.is_empty() {
|
||||||
|
@ -140,16 +140,21 @@ pub fn run_fail(&mut self) {
|
|||||||
|
|
||||||
/// If we have an expected file to write into, and `RUSTC_BLESS_TEST` is
|
/// If we have an expected file to write into, and `RUSTC_BLESS_TEST` is
|
||||||
/// set, then write the actual output into the file and return `true`.
|
/// set, then write the actual output into the file and return `true`.
|
||||||
|
///
|
||||||
|
/// We assume that `RUSTC_BLESS_TEST` contains the path to the original test's
|
||||||
|
/// source directory. That lets us bless the original snapshot file in the
|
||||||
|
/// source tree, not the copy in `rmake_out` that we would normally use.
|
||||||
fn maybe_bless_expected_file(&self, actual: &str) -> bool {
|
fn maybe_bless_expected_file(&self, actual: &str) -> bool {
|
||||||
let Some(ref expected_file) = self.expected_file else {
|
let Some(ref expected_file) = self.expected_file else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
if std::env::var("RUSTC_BLESS_TEST").is_err() {
|
let Ok(bless_dir) = std::env::var("RUSTC_BLESS_TEST") else {
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
println!("Blessing `{}`", expected_file.display());
|
let bless_file = Path::new(&bless_dir).join(expected_file);
|
||||||
fs::write(expected_file, actual);
|
println!("Blessing `{}`", bless_file.display());
|
||||||
|
fs::write(bless_file, actual);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user