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