1 extern crate compiletest_rs as compiletest;
3 use std::path::PathBuf;
4 use std::env::{set_var, var};
6 fn clippy_driver_path() -> PathBuf {
7 if let Some(path) = option_env!("CLIPPY_DRIVER_PATH") {
10 PathBuf::from(concat!("target/", env!("PROFILE"), "/clippy-driver"))
14 fn run_mode(dir: &'static str, mode: &'static str) {
15 let mut config = compiletest::Config::default();
17 let cfg_mode = mode.parse().expect("Invalid mode");
18 config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps -Dwarnings".to_owned());
19 if let Ok(name) = var::<&str>("TESTNAME") {
20 let s: String = name.to_owned();
21 config.filter = Some(s)
24 config.mode = cfg_mode;
26 let mut path = std::env::current_dir().unwrap();
27 path.push("target/debug/test_build_base");
30 config.src_base = PathBuf::from(format!("tests/{}", dir));
31 config.rustc_path = clippy_driver_path();
33 compiletest::run_tests(&config);
37 set_var("CLIPPY_DISABLE_DOCS_LINKS", "true");
38 set_var("CLIPPY_TESTS", "true");
39 set_var("RUST_BACKTRACE", "0");
45 run_mode("run-pass", "run-pass");