Make dogfood test output to seperate directory

This commit makes `cargo clippy` output the build artifacts to a
separate directory if the `CLIPPY_DOGFOOD` env var is set. This should
prevent dogfood builds from interfering with regular builds.

This should help with issue #2595.
This commit is contained in:
Michael Wright 2018-04-01 09:28:53 +02:00
parent b45801ff19
commit 1ab96db791
2 changed files with 18 additions and 0 deletions

View File

@ -77,10 +77,27 @@ where
if cfg!(windows) {
path.set_extension("exe");
}
let mut extra_envs = vec![];
if let Ok(_) = std::env::var("CLIPPY_DOGFOOD") {
let target_dir = std::env::var("CARGO_MANIFEST_DIR")
.map(|m| {
std::path::PathBuf::from(m)
.join("target")
.join("dogfood")
.to_string_lossy()
.into_owned()
})
.unwrap_or("clippy_dogfood".to_string());
extra_envs.push(("CARGO_TARGET_DIR", target_dir));
};
let exit_status = std::process::Command::new("cargo")
.args(&args)
.env("RUSTC_WRAPPER", path)
.env("CLIPPY_ARGS", clippy_args)
.envs(extra_envs)
.spawn()
.expect("could not run cargo")
.wait()

View File

@ -15,6 +15,7 @@ fn dogfood() {
.arg("cargo-clippy")
.arg("--manifest-path")
.arg(root_dir.join("Cargo.toml"))
.env("CLIPPY_DOGFOOD", "true")
.output()
.unwrap();
println!("status: {}", output.status);