]> git.lizzy.rs Git - rust.git/blob - tests/compiletest.rs
2fc1e615cff1965d9fd16b9f93234878c1ea2268
[rust.git] / tests / compiletest.rs
1 extern crate compiletest_rs as compiletest;
2
3 use std::path::PathBuf;
4
5 fn run_mode(mode: &'static str) {
6     // FIXME: read directories in sysroot/lib/rustlib and generate the test targets from that
7     let targets = &["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"];
8
9     for &target in targets {
10         let mut config = compiletest::default_config();
11         config.rustc_path = "target/debug/miri".into();
12         let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
13         config.run_lib_path = format!("{}/lib/rustlib/{}/lib", path, target);
14         let path = format!("--sysroot {}", path);
15         config.target_rustcflags = Some(path.clone());
16         config.host_rustcflags = Some(path);
17         let cfg_mode = mode.parse().ok().expect("Invalid mode");
18
19         config.mode = cfg_mode;
20         config.src_base = PathBuf::from(format!("tests/{}", mode));
21         config.target = target.to_owned();
22         compiletest::run_tests(&config);
23     }
24 }
25
26 #[test]
27 fn compile_test() {
28     run_mode("compile-fail");
29     run_mode("run-pass");
30 }