Skip to content

Commit 2af0021

Browse files
authored
Unrolled build for rust-lang#126270
Rollup merge of rust-lang#126270 - GuillaumeGomez:migrate-run-make-const_fn_mir, r=jieyouxu Migrate run make const fn mir Part of rust-lang#121876. r? ```@jieyouxu```
2 parents bfa098e + 5f4111f commit 2af0021

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

src/tools/run-make-support/src/diff/mod.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use regex::Regex;
22
use similar::TextDiff;
3-
use std::path::Path;
3+
use std::path::{Path, PathBuf};
44

55
use crate::drop_bomb::DropBomb;
6+
use crate::fs_wrapper;
67

78
#[cfg(test)]
89
mod tests;
@@ -17,6 +18,7 @@ pub fn diff() -> Diff {
1718
pub struct Diff {
1819
expected: Option<String>,
1920
expected_name: Option<String>,
21+
expected_file: Option<PathBuf>,
2022
actual: Option<String>,
2123
actual_name: Option<String>,
2224
normalizers: Vec<(String, String)>,
@@ -30,6 +32,7 @@ impl Diff {
3032
Self {
3133
expected: None,
3234
expected_name: None,
35+
expected_file: None,
3336
actual: None,
3437
actual_name: None,
3538
normalizers: Vec::new(),
@@ -40,9 +43,10 @@ impl Diff {
4043
/// Specify the expected output for the diff from a file.
4144
pub fn expected_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
4245
let path = path.as_ref();
43-
let content = std::fs::read_to_string(path).expect("failed to read file");
46+
let content = fs_wrapper::read_to_string(path);
4447
let name = path.to_string_lossy().to_string();
4548

49+
self.expected_file = Some(path.into());
4650
self.expected = Some(content);
4751
self.expected_name = Some(name);
4852
self
@@ -58,10 +62,7 @@ impl Diff {
5862
/// Specify the actual output for the diff from a file.
5963
pub fn actual_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
6064
let path = path.as_ref();
61-
let content = match std::fs::read_to_string(path) {
62-
Ok(c) => c,
63-
Err(e) => panic!("failed to read `{}`: {:?}", path.display(), e),
64-
};
65+
let content = fs_wrapper::read_to_string(path);
6566
let name = path.to_string_lossy().to_string();
6667

6768
self.actual = Some(content);
@@ -104,6 +105,15 @@ impl Diff {
104105
.to_string();
105106

106107
if !output.is_empty() {
108+
// If we can bless (meaning we have a file to write into and the `RUSTC_BLESS_TEST`
109+
// environment variable set), then we write into the file and return.
110+
if let Some(ref expected_file) = self.expected_file {
111+
if std::env::var("RUSTC_BLESS_TEST").is_ok() {
112+
println!("Blessing `{}`", expected_file.display());
113+
fs_wrapper::write(expected_file, actual);
114+
return;
115+
}
116+
}
107117
panic!(
108118
"test failed: `{}` is different from `{}`\n\n{}",
109119
expected_name, actual_name, output

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ run-make/compiler-lookup-paths-2/Makefile
1818
run-make/compiler-lookup-paths/Makefile
1919
run-make/compiler-rt-works-on-mingw/Makefile
2020
run-make/compressed-debuginfo/Makefile
21-
run-make/const_fn_mir/Makefile
2221
run-make/crate-hash-rustc-version/Makefile
2322
run-make/crate-name-priority/Makefile
2423
run-make/cross-lang-lto-clang/Makefile

tests/run-make/const_fn_mir/Makefile

-6
This file was deleted.

tests/run-make/const_fn_mir/rmake.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// The `needs-unwind -Cpanic=abort` gives a different MIR output.
2+
3+
use run_make_support::{cwd, diff, rustc};
4+
5+
fn main() {
6+
rustc().input("main.rs").emit("mir").output("dump-actual.mir").run();
7+
diff().expected_file("dump.mir").actual_file("dump-actual.mir").run();
8+
}

0 commit comments

Comments
 (0)