2016-04-22 03:34:14 -05:00
|
|
|
extern crate compiletest_rs as compiletest;
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
fn run_mode(mode: &'static str) {
|
2016-05-31 05:05:25 -05:00
|
|
|
// FIXME: read directories in sysroot/lib/rustlib and generate the test targets from that
|
|
|
|
let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
|
2016-04-22 03:34:14 -05:00
|
|
|
|
2016-05-31 05:05:25 -05:00
|
|
|
for &target in targets {
|
|
|
|
let mut config = compiletest::default_config();
|
|
|
|
config.rustc_path = "target/debug/miri".into();
|
|
|
|
let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
|
|
|
|
config.run_lib_path = format!("{}/lib/rustlib/{}/lib", path, target);
|
|
|
|
let path = format!("--sysroot {}", path);
|
|
|
|
config.target_rustcflags = Some(path.clone());
|
|
|
|
config.host_rustcflags = Some(path);
|
|
|
|
let cfg_mode = mode.parse().ok().expect("Invalid mode");
|
2016-04-22 03:34:14 -05:00
|
|
|
|
2016-05-31 05:05:25 -05:00
|
|
|
config.mode = cfg_mode;
|
|
|
|
config.src_base = PathBuf::from(format!("tests/{}", mode));
|
|
|
|
config.target = target.to_owned();
|
|
|
|
compiletest::run_tests(&config);
|
|
|
|
}
|
2016-04-22 03:34:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn compile_test() {
|
|
|
|
run_mode("compile-fail");
|
|
|
|
run_mode("run-pass");
|
2016-04-22 07:38:46 -05:00
|
|
|
run_mode("run-fail");
|
2016-04-22 03:34:14 -05:00
|
|
|
}
|