remove xargo logic; instead rely on MIRI_SYSROOT being set to run full MIR tests

This commit is contained in:
Ralf Jung 2018-07-12 11:01:09 +02:00
parent 01578ca6b3
commit 8ce16a7c30
2 changed files with 40 additions and 39 deletions

View File

@ -31,4 +31,3 @@ cargo_miri = ["cargo_metadata"]
[dev-dependencies]
compiletest_rs = { version = "0.3.4", features = ["tmp"] }
dirs = "1.0.2"

View File

@ -1,7 +1,6 @@
#![feature(slice_concat_ext)]
extern crate compiletest_rs as compiletest;
extern crate dirs;
use std::slice::SliceConcatExt;
use std::path::{PathBuf, Path};
@ -31,7 +30,21 @@ fn rustc_lib_path() -> PathBuf {
option_env!("RUSTC_LIB_PATH").unwrap().into()
}
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: bool) {
fn have_fullmir() -> bool {
// We assume we have full MIR when MIRI_SYSROOT is set or when we are in rustc
std::env::var("MIRI_SYSROOT").is_ok() || rustc_test_suite().is_some()
}
fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: bool) {
if need_fullmir && !have_fullmir() {
eprintln!(
"## Skipping compile-fail tests in {} against miri for target {} due to missing mir",
path,
target
);
return;
}
eprintln!(
"## Running compile-fail tests in {} against miri for target {}",
path,
@ -45,28 +58,16 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
config.run_lib_path = rustc_lib_path();
config.compile_lib_path = rustc_lib_path();
}
// if we are building as part of the rustc test suite, we already have fullmir for everything
if fullmir && rustc_test_suite().is_none() {
if host != target {
// skip fullmir on nonhost
return;
}
let sysroot = dirs::home_dir().unwrap()
.join(".xargo")
.join("HOST");
flags.push(format!("--sysroot {}", sysroot.to_str().unwrap()));
config.src_base = PathBuf::from(path.to_string());
} else {
flags.push(format!("--sysroot {}", sysroot.to_str().unwrap()));
config.src_base = PathBuf::from(path.to_string());
}
flags.push(format!("--sysroot {}", sysroot.display()));
config.src_base = PathBuf::from(path.to_string());
flags.push("-Zmir-emit-validate=1".to_owned());
config.target_rustcflags = Some(flags.join(" "));
config.target = target.to_owned();
config.host = host.to_owned();
compiletest::run_tests(&config);
}
fn run_pass(path: &str) {
fn rustc_pass(sysroot: &Path, path: &str) {
eprintln!("## Running run-pass tests in {} against rustc", path);
let mut config = compiletest::Config::default().tempdir();
config.mode = "run-pass".parse().expect("Invalid mode");
@ -75,7 +76,7 @@ fn run_pass(path: &str) {
config.rustc_path = rustc_path;
config.run_lib_path = rustc_lib_path();
config.compile_lib_path = rustc_lib_path();
config.target_rustcflags = Some(format!("-Dwarnings --sysroot {}", get_sysroot().display()));
config.target_rustcflags = Some(format!("-Dwarnings --sysroot {}", sysroot.display()));
} else {
config.target_rustcflags = Some("-Dwarnings".to_owned());
}
@ -83,7 +84,16 @@ fn run_pass(path: &str) {
compiletest::run_tests(&config);
}
fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: bool, opt: bool) {
if need_fullmir && !have_fullmir() {
eprintln!(
"## Skipping run-pass tests in {} against miri for target {} due to missing mir",
path,
target
);
return;
}
let opt_str = if opt { " with optimizations" } else { "" };
eprintln!(
"## Running run-pass tests in {} against miri for target {}{}",
@ -102,21 +112,9 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
config.compile_lib_path = rustc_lib_path();
}
let mut flags = Vec::new();
// Control miri logging. This is okay despite concurrent test execution as all tests
// will set this env var to the same value.
env::set_var("MIRI_LOG", "warn");
// if we are building as part of the rustc test suite, we already have fullmir for everything
if fullmir && rustc_test_suite().is_none() {
if host != target {
// skip fullmir on nonhost
return;
}
let sysroot = dirs::home_dir().unwrap()
.join(".xargo")
.join("HOST");
flags.push(format!("--sysroot {}", sysroot.display()));
if have_fullmir() {
flags.push("-Zmiri-start-fn".to_owned());
flags.push(format!("--sysroot {}", sysroot.to_str().unwrap()));
}
if opt {
flags.push("-Zmir-opt-level=3".to_owned());
@ -125,6 +123,9 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
// For now, only validate without optimizations. Inlining breaks validation.
flags.push("-Zmir-emit-validate=1".to_owned());
}
// Control miri logging. This is okay despite concurrent test execution as all tests
// will set this env var to the same value.
env::set_var("MIRI_LOG", "warn");
config.target_rustcflags = Some(flags.join(" "));
compiletest::run_tests(&config);
}
@ -181,9 +182,9 @@ fn run_pass_miri(opt: bool) {
let host = get_host();
for_all_targets(&sysroot, |target| {
miri_pass("tests/run-pass", &target, &host, false, opt);
miri_pass(&sysroot, "tests/run-pass", &target, &host, false, opt);
});
miri_pass("tests/run-pass-fullmir", &host, &host, true, opt);
miri_pass(&sysroot, "tests/run-pass-fullmir", &host, &host, true, opt);
}
#[test]
@ -201,8 +202,9 @@ fn run_pass_miri_opt() {
#[test]
fn run_pass_rustc() {
run_pass("tests/run-pass");
run_pass("tests/run-pass-fullmir");
let sysroot = get_sysroot();
rustc_pass(&sysroot, "tests/run-pass");
rustc_pass(&sysroot, "tests/run-pass-fullmir");
}
#[test]