1 // Dogfood cannot run on Windows
5 use std::lazy::SyncLazy;
6 use std::path::PathBuf;
7 use std::process::Command;
11 static CLIPPY_PATH: SyncLazy<PathBuf> = SyncLazy::new(|| cargo::TARGET_LIB.join("cargo-clippy"));
15 // run clippy on itself and fail the test if lint warnings are reported
16 if cargo::is_rustc_test_suite() {
19 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
21 let mut command = Command::new(&*CLIPPY_PATH);
23 .current_dir(root_dir)
24 .env("CLIPPY_DOGFOOD", "1")
25 .env("CARGO_INCREMENTAL", "0")
26 .arg("clippy-preview")
28 .arg("--all-features")
30 .args(&["-D", "clippy::all"])
31 .args(&["-D", "clippy::pedantic"])
32 .arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
34 // internal lints only exist if we build with the internal-lints feature
35 if cfg!(feature = "internal-lints") {
36 command.args(&["-D", "clippy::internal"]);
39 let output = command.output().unwrap();
41 println!("status: {}", output.status);
42 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
43 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
45 assert!(output.status.success());
49 fn dogfood_subprojects() {
50 // run clippy on remaining subprojects and fail the test if lint warnings are reported
51 if cargo::is_rustc_test_suite() {
54 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
57 "clippy_workspace_tests",
58 "clippy_workspace_tests/src",
59 "clippy_workspace_tests/subcrate",
60 "clippy_workspace_tests/subcrate/src",
64 let output = Command::new(&*CLIPPY_PATH)
65 .current_dir(root_dir.join(d))
66 .env("CLIPPY_DOGFOOD", "1")
67 .env("CARGO_INCREMENTAL", "0")
70 .args(&["-D", "clippy::all"])
71 .args(&["-D", "clippy::pedantic"])
72 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
75 println!("status: {}", output.status);
76 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
77 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
79 assert!(output.status.success());