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.
This commit is contained in:
Alex Crichton 2019-09-18 18:07:57 -07:00
parent eadbaec938
commit ef5b89ce28

View File

@ -1694,8 +1694,17 @@ pub fn process<T: AsRef<OsStr>>(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
}