]> git.lizzy.rs Git - rust.git/blob - tests/compile-test.rs
Run rustfmt
[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, temp_dir};
5
6 fn run_mode(dir: &'static str, mode: &'static str) {
7     let mut config = compiletest::default_config();
8
9     let cfg_mode = mode.parse().ok().expect("Invalid mode");
10     config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps".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     if cfg!(windows) {
18         // work around https://github.com/laumann/compiletest-rs/issues/35 on msvc windows
19         config.build_base = temp_dir();
20     }
21     config.src_base = PathBuf::from(format!("tests/{}", dir));
22
23     compiletest::run_tests(&config);
24 }
25
26 fn prepare_env() {
27     set_var("CLIPPY_DISABLE_WIKI_LINKS", "true");
28 }
29
30 #[test]
31 #[cfg(not(feature = "test-regex_macros"))]
32 fn compile_test() {
33     prepare_env();
34     run_mode("run-pass", "run-pass");
35     run_mode("compile-fail", "compile-fail");
36 }
37
38 #[test]
39 #[cfg(feature = "test-regex_macros")]
40 fn compile_test() {
41     prepare_env();
42     run_mode("run-pass-regex_macros", "run-pass");
43     run_mode("compile-fail-regex_macros", "compile-fail");
44 }