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 output = if cfg!(feature = "internal-lints") {
22 // with internal lints and internal warnings
23 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")
30 .args(&["--features", "internal-lints"])
32 .args(&["-D", "clippy::all"])
33 .args(&["-D", "clippy::pedantic"])
34 .args(&["-D", "clippy::internal"])
35 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
39 // without internal lints or warnings
40 Command::new(&*CLIPPY_PATH)
41 .current_dir(root_dir)
42 .env("CLIPPY_DOGFOOD", "1")
43 .env("CARGO_INCREMENTAL", "0")
44 .arg("clippy-preview")
46 .arg("--all-features")
48 .args(&["-D", "clippy::all"])
49 .args(&["-D", "clippy::pedantic"])
50 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
54 println!("status: {}", output.status);
55 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
56 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
58 assert!(output.status.success());
62 fn dogfood_subprojects() {
63 // run clippy on remaining subprojects and fail the test if lint warnings are reported
64 if cargo::is_rustc_test_suite() {
67 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
70 "clippy_workspace_tests",
71 "clippy_workspace_tests/src",
72 "clippy_workspace_tests/subcrate",
73 "clippy_workspace_tests/subcrate/src",
77 let output = Command::new(&*CLIPPY_PATH)
78 .current_dir(root_dir.join(d))
79 .env("CLIPPY_DOGFOOD", "1")
80 .env("CARGO_INCREMENTAL", "0")
83 .args(&["-D", "clippy::all"])
84 .args(&["-D", "clippy::pedantic"])
85 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
88 println!("status: {}", output.status);
89 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
90 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
92 assert!(output.status.success());