+// Dogfood cannot run on Windows
+#![cfg(not(windows))]
+
+use lazy_static::lazy_static;
use std::path::PathBuf;
use std::process::Command;
-#[allow(dead_code)]
mod cargo;
-fn clippy_path() -> PathBuf {
- let build_info = cargo::BuildInfo::new();
- build_info.target_lib().join("cargo-clippy")
+lazy_static! {
+ static ref CLIPPY_PATH: PathBuf = cargo::TARGET_LIB.join("cargo-clippy");
}
#[test]
fn dogfood_clippy() {
// run clippy on itself and fail the test if lint warnings are reported
- if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
+ if cargo::is_rustc_test_suite() {
return;
}
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
- let clippy_binary = clippy_path();
- let output = Command::new(clippy_binary)
+ let output = Command::new(&*CLIPPY_PATH)
.current_dir(root_dir)
.env("CLIPPY_DOGFOOD", "1")
.env("CARGO_INCREMENTAL", "0")
#[test]
fn dogfood_subprojects() {
// run clippy on remaining subprojects and fail the test if lint warnings are reported
- if option_env!("RUSTC_TEST_SUITE").is_some() || cfg!(windows) {
+ if cargo::is_rustc_test_suite() {
return;
}
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
- let clippy_binary = clippy_path();
for d in &[
"clippy_workspace_tests",
"clippy_dev",
"rustc_tools_util",
] {
- let output = Command::new(&clippy_binary)
+ let output = Command::new(&*CLIPPY_PATH)
.current_dir(root_dir.join(d))
.env("CLIPPY_DOGFOOD", "1")
.env("CARGO_INCREMENTAL", "0")