Skip to content

Commit 88fc42b

Browse files
committed
compiletest: no need to call rustc here
1 parent c9decd3 commit 88fc42b

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

tests/compiletest.rs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,11 @@ use colored::*;
99
use compiletest_rs as compiletest;
1010

1111
fn miri_path() -> PathBuf {
12-
if rustc_test_suite().is_some() {
13-
PathBuf::from(option_env!("MIRI_PATH").unwrap())
14-
} else {
15-
PathBuf::from(env!("CARGO_BIN_EXE_miri"))
16-
}
17-
}
18-
19-
fn rustc_test_suite() -> Option<PathBuf> {
20-
option_env!("RUSTC_TEST_SUITE").map(PathBuf::from)
21-
}
22-
23-
fn rustc_lib_path() -> PathBuf {
24-
option_env!("RUSTC_LIB_PATH").unwrap().into()
12+
PathBuf::from(option_env!("MIRI_PATH").unwrap_or(env!("CARGO_BIN_EXE_miri")))
2513
}
2614

2715
fn run_tests(mode: &str, path: &str, target: &str) {
28-
let in_rustc_test_suite = rustc_test_suite().is_some();
16+
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();
2917
// Add some flags we always want.
3018
let mut flags = Vec::new();
3119
flags.push("--edition 2018".to_owned());
@@ -50,9 +38,9 @@ fn run_tests(mode: &str, path: &str, target: &str) {
5038
let mut config = compiletest::Config::default().tempdir();
5139
config.mode = mode.parse().expect("Invalid mode");
5240
config.rustc_path = miri_path();
53-
if in_rustc_test_suite {
54-
config.run_lib_path = rustc_lib_path();
55-
config.compile_lib_path = rustc_lib_path();
41+
if let Some(lib_path) = option_env!("RUSTC_LIB_PATH") {
42+
config.run_lib_path = PathBuf::from(lib_path);
43+
config.compile_lib_path = PathBuf::from(lib_path);
5644
}
5745
config.filter = env::args().nth(1);
5846
config.host = get_host();
@@ -91,15 +79,9 @@ fn miri_pass(path: &str, target: &str) {
9179
}
9280

9381
fn get_host() -> String {
94-
let rustc = rustc_test_suite().unwrap_or(PathBuf::from("rustc"));
95-
let rustc_version = std::process::Command::new(rustc)
96-
.arg("-vV")
97-
.output()
98-
.expect("rustc not found for -vV")
99-
.stdout;
100-
let rustc_version = std::str::from_utf8(&rustc_version).expect("rustc -vV is not utf8");
101-
let version_meta = rustc_version::version_meta_for(&rustc_version)
102-
.expect("failed to parse rustc version info");
82+
let version_meta = rustc_version::VersionMeta::for_command(
83+
std::process::Command::new(miri_path())
84+
).expect("failed to parse rustc version info");
10385
version_meta.host
10486
}
10587

0 commit comments

Comments
 (0)