From ef5b89ce284b00b72d475de287af9a6836259abd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 18 Sep 2019 18:07:57 -0700 Subject: [PATCH] Remove all `CARGO_*` env vars in tests Usage of `CARGO_PROFILE_*` is generating unexpected warnings in tests in rust-lang/rust#64316 so let's just blanket remove every env var that has a `CARGO_*` prefix which generally means Cargo-specific env vars. Tests practically all assume that they have blank configs right now. --- crates/cargo-test-support/src/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/cargo-test-support/src/lib.rs b/crates/cargo-test-support/src/lib.rs index 2ceb6bf65..f8e29b62f 100644 --- a/crates/cargo-test-support/src/lib.rs +++ b/crates/cargo-test-support/src/lib.rs @@ -1694,8 +1694,17 @@ pub fn process>(t: T) -> cargo::util::ProcessBuilder { fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { let mut p = cargo::util::process(t); + + // In general just clear out all cargo-specific configuration already in the + // environment. Our tests all assume a "default configuration" unless + // specified otherwise. + for (k, _v) in env::vars() { + if k.starts_with("CARGO_") { + p.env_remove(&k); + } + } + p.cwd(&paths::root()) - .env_remove("CARGO_HOME") .env("HOME", paths::home()) .env("CARGO_HOME", paths::home().join(".cargo")) .env("__CARGO_TEST_ROOT", paths::root()) @@ -1707,10 +1716,6 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { // stable channel yet. Once incremental support hits the stable compiler we // can switch this to one and then fix the tests. .env("CARGO_INCREMENTAL", "0") - // This env var can switch the git backend from libgit2 to git2-curl, which - // can tweak error messages and cause some tests to fail, so let's forcibly - // remove it. - .env_remove("CARGO_HTTP_CHECK_REVOKE") .env_remove("__CARGO_DEFAULT_LIB_METADATA") .env_remove("RUSTC") .env_remove("RUSTDOC") @@ -1722,12 +1727,10 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { .env_remove("USER") // not set on some rust-lang docker images .env_remove("MFLAGS") .env_remove("MAKEFLAGS") - .env_remove("CARGO_MAKEFLAGS") .env_remove("GIT_AUTHOR_NAME") .env_remove("GIT_AUTHOR_EMAIL") .env_remove("GIT_COMMITTER_NAME") .env_remove("GIT_COMMITTER_EMAIL") - .env_remove("CARGO_TARGET_DIR") // we assume 'target' .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows p }