]> git.lizzy.rs Git - rust.git/blob - tests/compile-test.rs
Merge pull request #1975 from bjgill/clippy--all
[rust.git] / tests / compile-test.rs
1 extern crate compiletest_rs as compiletest;
2
3 use std::path::PathBuf;
4 use std::env::{set_var, var};
5
6 fn run_mode(dir: &'static str, mode: &'static str) {
7     let mut config = compiletest::Config::default();
8
9     let cfg_mode = mode.parse().expect("Invalid mode");
10     config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps -Dwarnings".to_owned());
11     if let Ok(name) = var::<&str>("TESTNAME") {
12         let s: String = name.to_owned();
13         config.filter = Some(s)
14     }
15
16     config.mode = cfg_mode;
17     config.build_base = PathBuf::from("target/debug/test_build_base");
18     config.src_base = PathBuf::from(format!("tests/{}", dir));
19
20     compiletest::run_tests(&config);
21 }
22
23 fn prepare_env() {
24     set_var("CLIPPY_DISABLE_WIKI_LINKS", "true");
25 }
26
27 #[test]
28 fn compile_test() {
29     prepare_env();
30     run_mode("run-pass", "run-pass");
31     run_mode("ui", "ui");
32     #[cfg(target_os = "windows")] run_mode("ui-windows", "ui");
33     #[cfg(not(target_os = "windows"))] run_mode("ui-posix", "ui");
34 }