1 use std::path::PathBuf;
2 use std::process::Command;
7 fn clippy_path() -> PathBuf {
8 let build_info = cargo::BuildInfo::new();
9 build_info.target_lib().join("cargo-clippy")
14 // run clippy on itself and fail the test if lint warnings are reported
15 if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
18 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
19 let clippy_binary = clippy_path();
21 let output = Command::new(clippy_binary)
22 .current_dir(root_dir)
23 .env("CLIPPY_DOGFOOD", "1")
24 .env("CARGO_INCREMENTAL", "0")
25 .arg("clippy-preview")
27 .arg("--all-features")
29 .args(&["-D", "clippy::all"])
30 .args(&["-D", "clippy::internal"])
31 .args(&["-D", "clippy::pedantic"])
32 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
35 println!("status: {}", output.status);
36 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
37 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
39 assert!(output.status.success());
43 fn dogfood_subprojects() {
44 // run clippy on remaining subprojects and fail the test if lint warnings are reported
45 if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
48 let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
49 let clippy_binary = clippy_path();
52 "clippy_workspace_tests",
53 "clippy_workspace_tests/src",
54 "clippy_workspace_tests/subcrate",
55 "clippy_workspace_tests/subcrate/src",
59 let output = Command::new(&clippy_binary)
60 .current_dir(root_dir.join(d))
61 .env("CLIPPY_DOGFOOD", "1")
62 .env("CARGO_INCREMENTAL", "0")
65 .args(&["-D", "clippy::all"])
66 .args(&["-D", "clippy::pedantic"])
67 .arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
70 println!("status: {}", output.status);
71 println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
72 println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
74 assert!(output.status.success());