Skip to content

Commit d96c050

Browse files
committed
Auto merge of #7386 - alexcrichton:less-env-leak, r=ehuss
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.
2 parents d3df047 + ef5b89c commit d96c050

File tree

1 file changed

+10
-7
lines changed
  • crates/cargo-test-support/src

1 file changed

+10
-7
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,8 +1694,17 @@ pub fn process<T: AsRef<OsStr>>(t: T) -> cargo::util::ProcessBuilder {
16941694

16951695
fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
16961696
let mut p = cargo::util::process(t);
1697+
1698+
// In general just clear out all cargo-specific configuration already in the
1699+
// environment. Our tests all assume a "default configuration" unless
1700+
// specified otherwise.
1701+
for (k, _v) in env::vars() {
1702+
if k.starts_with("CARGO_") {
1703+
p.env_remove(&k);
1704+
}
1705+
}
1706+
16971707
p.cwd(&paths::root())
1698-
.env_remove("CARGO_HOME")
16991708
.env("HOME", paths::home())
17001709
.env("CARGO_HOME", paths::home().join(".cargo"))
17011710
.env("__CARGO_TEST_ROOT", paths::root())
@@ -1707,10 +1716,6 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
17071716
// stable channel yet. Once incremental support hits the stable compiler we
17081717
// can switch this to one and then fix the tests.
17091718
.env("CARGO_INCREMENTAL", "0")
1710-
// This env var can switch the git backend from libgit2 to git2-curl, which
1711-
// can tweak error messages and cause some tests to fail, so let's forcibly
1712-
// remove it.
1713-
.env_remove("CARGO_HTTP_CHECK_REVOKE")
17141719
.env_remove("__CARGO_DEFAULT_LIB_METADATA")
17151720
.env_remove("RUSTC")
17161721
.env_remove("RUSTDOC")
@@ -1722,12 +1727,10 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder {
17221727
.env_remove("USER") // not set on some rust-lang docker images
17231728
.env_remove("MFLAGS")
17241729
.env_remove("MAKEFLAGS")
1725-
.env_remove("CARGO_MAKEFLAGS")
17261730
.env_remove("GIT_AUTHOR_NAME")
17271731
.env_remove("GIT_AUTHOR_EMAIL")
17281732
.env_remove("GIT_COMMITTER_NAME")
17291733
.env_remove("GIT_COMMITTER_EMAIL")
1730-
.env_remove("CARGO_TARGET_DIR") // we assume 'target'
17311734
.env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows
17321735
p
17331736
}

0 commit comments

Comments
 (0)