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 flags = format!("--sysroot {} -Dwarnings", 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 {
25 let stderr = std::io::stderr();
26 write!(stderr.lock(), "running tests for target {}", target).unwrap();
27 let mut config = compiletest::default_config();
28 config.host_rustcflags = Some(flags.clone());
29 config.mode = mode.parse().expect("Invalid mode");
30 config.run_lib_path = format!("{}/lib/rustlib/{}/lib", sysroot, target);
31 config.rustc_path = "target/debug/miri".into();
32 config.src_base = PathBuf::from(format!("tests/{}", mode));
33 config.target = target.to_owned();
34 config.target_rustcflags = Some(flags.clone());
35 compiletest::run_tests(&config);
41 run_mode("compile-fail");