1 extern crate compiletest_rs as compiletest;
3 use std::path::PathBuf;
5 fn run_mode(mode: &'static str) {
6 // Disable rustc's new error fomatting. It breaks these tests.
7 std::env::remove_var("RUST_NEW_ERROR_FORMAT");
9 // Taken from https://github.com/Manishearth/rust-clippy/pull/911.
10 let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
11 let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
12 let sysroot = match (home, toolchain) {
13 (Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
14 _ => option_env!("RUST_SYSROOT")
15 .expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
18 let sysroot_flag = format!("--sysroot {}", sysroot);
20 // FIXME: read directories in sysroot/lib/rustlib and generate the test targets from that
21 let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
23 for &target in targets {
24 let mut config = compiletest::default_config();
25 config.host_rustcflags = Some(sysroot_flag.clone());
26 config.mode = mode.parse().ok().expect("Invalid mode");
27 config.run_lib_path = format!("{}/lib/rustlib/{}/lib", sysroot, target);
28 config.rustc_path = "target/debug/miri".into();
29 config.src_base = PathBuf::from(format!("tests/{}", mode));
30 config.target = target.to_owned();
31 config.target_rustcflags = Some(sysroot_flag.clone());
32 compiletest::run_tests(&config);
38 run_mode("compile-fail");