Skip to content

Get the test suite working inside the rustc test suite #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ macro_rules! eprintln {
}
}

const MIRI_PATH: &'static str = concat!("target/", env!("PROFILE"), "/miri");
fn miri_path() -> PathBuf {
if rustc_test_suite().is_some() {
PathBuf::from(option_env!("MIRI_PATH").unwrap())
} else {
PathBuf::from(concat!("target/", env!("PROFILE"), "/miri"))
}
}

fn rustc_test_suite() -> Option<PathBuf> {
option_env!("RUSTC_TEST_SUITE").map(PathBuf::from)
}

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) {
eprintln!(
Expand All @@ -23,9 +37,14 @@ fn compile_fail(sysroot: &Path, path: &str, target: &str, host: &str, fullmir: b
);
let mut config = compiletest::default_config();
config.mode = "compile-fail".parse().expect("Invalid mode");
config.rustc_path = MIRI_PATH.into();
config.rustc_path = miri_path();
let mut flags = Vec::new();
if fullmir {
if rustc_test_suite().is_some() {
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;
Expand All @@ -50,7 +69,14 @@ fn run_pass(path: &str) {
let mut config = compiletest::default_config();
config.mode = "run-pass".parse().expect("Invalid mode");
config.src_base = PathBuf::from(path);
config.target_rustcflags = Some("-Dwarnings".to_string());
if let Some(rustc_path) = rustc_test_suite() {
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()));
} else {
config.target_rustcflags = Some("-Dwarnings".to_owned());
}
config.host_rustcflags = Some("-Dwarnings".to_string());
compiletest::run_tests(&config);
}
Expand All @@ -68,9 +94,14 @@ fn miri_pass(path: &str, target: &str, host: &str, fullmir: bool, opt: bool) {
config.src_base = PathBuf::from(path);
config.target = target.to_owned();
config.host = host.to_owned();
config.rustc_path = MIRI_PATH.into();
config.rustc_path = miri_path();
if rustc_test_suite().is_some() {
config.run_lib_path = rustc_lib_path();
config.compile_lib_path = rustc_lib_path();
}
let mut flags = Vec::new();
if fullmir {
// 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;
Expand Down