1 use lazy_static::lazy_static;
2 use std::path::PathBuf;
3 use std::process::Command;
9 static ref CLIPPY_PATH: PathBuf = {
10 let build_info = cargo::BuildInfo::new();
11 build_info.target_lib().join("cargo-clippy")
17 // run clippy on itself and fail the test if lint warnings are reported
18 if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
21 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
23 let output = Command::new(&*CLIPPY_PATH)
24 .current_dir(root_dir)
25 .env("CLIPPY_DOGFOOD", "1")
26 .env("CARGO_INCREMENTAL", "0")
27 .arg("clippy-preview")
29 .arg("--all-features")
31 .args(&["-D", "clippy::all"])
32 .args(&["-D", "clippy::internal"])
33 .args(&["-D", "clippy::pedantic"])
34 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
37 println!("status: {}", output.status);
38 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
39 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
41 assert!(output.status.success());
45 fn dogfood_subprojects() {
46 // run clippy on remaining subprojects and fail the test if lint warnings are reported
47 if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
50 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
53 "clippy_workspace_tests",
54 "clippy_workspace_tests/src",
55 "clippy_workspace_tests/subcrate",
56 "clippy_workspace_tests/subcrate/src",
60 let output = Command::new(&*CLIPPY_PATH)
61 .current_dir(root_dir.join(d))
62 .env("CLIPPY_DOGFOOD", "1")
63 .env("CARGO_INCREMENTAL", "0")
66 .args(&["-D", "clippy::all"])
67 .args(&["-D", "clippy::pedantic"])
68 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
71 println!("status: {}", output.status);
72 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
73 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
75 assert!(output.status.success());