rust/tests/dogfood.rs

50 lines
1.3 KiB
Rust
Raw Normal View History

2016-02-17 11:16:29 -06:00
#![feature(test, plugin)]
#![plugin(clippy)]
#![deny(clippy, clippy_pedantic)]
2015-11-18 10:09:48 -06:00
extern crate compiletest_rs as compiletest;
extern crate test;
2015-11-18 10:09:48 -06:00
use std::env::{var, set_var};
use std::path::PathBuf;
use test::TestPaths;
2015-11-18 10:09:48 -06:00
#[test]
fn dogfood() {
// don't run dogfood on travis, cargo-clippy already runs clippy on itself
if let Ok(travis) = var("TRAVIS") {
if travis == "true" {
return;
}
}
2015-11-18 10:09:48 -06:00
let mut config = compiletest::default_config();
let cfg_mode = "run-fail".parse().expect("Invalid mode");
2015-11-18 10:09:48 -06:00
let mut s = String::new();
2017-05-17 07:45:36 -05:00
s.push_str(" -L clippy_tests/target/debug/");
s.push_str(" -L clippy_tests/target/debug/deps");
2016-10-22 09:16:55 -05:00
s.push_str(" -Zextra-plugins=clippy -Ltarget_recur/debug -Dwarnings -Dclippy_pedantic -Dclippy -Dclippy_internal");
2015-11-18 10:09:48 -06:00
config.target_rustcflags = Some(s);
2016-02-17 11:16:29 -06:00
if let Ok(name) = var("TESTNAME") {
config.filter = Some(name.to_owned())
2015-11-18 10:09:48 -06:00
}
config.mode = cfg_mode;
config.verbose = true;
2015-11-18 10:09:48 -06:00
let files = ["src/main.rs", "src/lib.rs", "clippy_lints/src/lib.rs"];
2016-02-17 11:16:29 -06:00
for file in &files {
let paths = TestPaths {
base: PathBuf::new(),
file: PathBuf::from(file),
relative_dir: PathBuf::new(),
};
2016-02-17 11:16:29 -06:00
set_var("CLIPPY_DOGFOOD", "tastes like chicken");
compiletest::runtest::run(config.clone(), &paths);
}
2015-11-18 10:09:48 -06:00
}