Skip to content

Commit a6cd7a2

Browse files
committed
Also move some compile-fail tests to fullmir-only
1 parent b001b55 commit a6cd7a2

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

tests/compiletest.rs

+24-14
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ extern crate compiletest_rs as compiletest;
33
use std::path::{PathBuf, Path};
44
use std::io::Write;
55

6-
fn compile_fail(sysroot: &Path) {
7-
let flags = format!("--sysroot {} -Dwarnings", sysroot.to_str().expect("non utf8 path"));
8-
for_all_targets(sysroot, |target| {
9-
let mut config = compiletest::default_config();
10-
config.host_rustcflags = Some(flags.clone());
11-
config.mode = "compile-fail".parse().expect("Invalid mode");
12-
config.run_lib_path = Path::new(sysroot).join("lib").join("rustlib").join(&target).join("lib");
13-
config.rustc_path = "target/debug/miri".into();
14-
config.src_base = PathBuf::from("tests/compile-fail".to_string());
15-
config.target = target.to_owned();
16-
config.target_rustcflags = Some(flags.clone());
17-
compiletest::run_tests(&config);
18-
});
6+
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) {
7+
let mut config = compiletest::default_config();
8+
config.mode = "compile-fail".parse().expect("Invalid mode");
9+
config.rustc_path = "target/debug/miri".into();
10+
if fullmir {
11+
if host != target {
12+
// skip fullmir on nonhost
13+
return;
14+
}
15+
let sysroot = Path::new(&std::env::var("HOME").unwrap()).join(".xargo").join("HOST");
16+
config.target_rustcflags = Some(format!("--sysroot {}", sysroot.to_str().unwrap()));
17+
config.src_base = PathBuf::from(path.to_string());
18+
} else {
19+
config.target_rustcflags = Some(format!("--sysroot {}", sysroot.to_str().unwrap()));
20+
config.src_base = PathBuf::from(path.to_string());
21+
}
22+
config.target = target.to_owned();
23+
compiletest::run_tests(&config);
1924
}
2025

2126
fn run_pass() {
@@ -35,6 +40,10 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool) {
3540
config.host = host.to_owned();
3641
config.rustc_path = PathBuf::from("target/debug/miri");
3742
if fullmir {
43+
if host != target {
44+
// skip fullmir on nonhost
45+
return;
46+
}
3847
let sysroot = Path::new(&std::env::var("HOME").unwrap()).join(".xargo").join("HOST");
3948
config.target_rustcflags = Some(format!("--sysroot {}", sysroot.to_str().unwrap()));
4049
}
@@ -203,9 +212,10 @@ fn compile_test() {
203212
run_pass();
204213
for_all_targets(sysroot, |target| {
205214
miri_pass("tests/run-pass", &target, host, false);
215+
compile_fail(sysroot, "tests/compile-fail", &target, host, false);
206216
});
207217
miri_pass("tests/run-pass-fullmir", host, host, true);
208-
compile_fail(sysroot);
218+
compile_fail(sysroot, "tests/compile-fail-fullmir", host, host, true);
209219
}
210220
}
211221

0 commit comments

Comments
 (0)