Skip to content

Commit ff31445

Browse files
committed
Set RUSTUP_TOOLCHAIN_SOURCE in rustup tests
1 parent 367fd9f commit ff31445

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/testsuite/rustup.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ fn real_rustc_wrapper(bin_dir: &Path, message: &str) -> PathBuf {
5555
// The toolchain rustc needs to call the real rustc. In order to do that,
5656
// it needs to restore or clear the RUSTUP environment variables so that
5757
// if rustup is installed, it will call the correct rustc.
58+
let rustup_toolchain_source_setup = match std::env::var_os("RUSTUP_TOOLCHAIN_SOURCE") {
59+
Some(t) => format!(
60+
".env(\"RUSTUP_TOOLCHAIN_SOURCE\", \"{}\")",
61+
t.into_string().unwrap()
62+
),
63+
None => format!(".env_remove(\"RUSTUP_TOOLCHAIN_SOURCE\")"),
64+
};
5865
let rustup_toolchain_setup = match std::env::var_os("RUSTUP_TOOLCHAIN") {
5966
Some(t) => format!(
6067
".env(\"RUSTUP_TOOLCHAIN\", \"{}\")",
@@ -78,6 +85,7 @@ fn real_rustc_wrapper(bin_dir: &Path, message: &str) -> PathBuf {
7885
eprintln!("{message}");
7986
let r = std::process::Command::new(env!("CARGO_RUSTUP_TEST_real_rustc"))
8087
.args(std::env::args_os().skip(1))
88+
{rustup_toolchain_source_setup}
8189
{rustup_toolchain_setup}
8290
{rustup_home_setup}
8391
.status();
@@ -162,6 +170,7 @@ fn typical_rustup() {
162170
// `~/.cargo/bin/rustc to use our custom rustup proxies.
163171
let path = prepend_path(&cargo_bin);
164172
p.cargo("check")
173+
.env("RUSTUP_TOOLCHAIN_SOURCE", "default")
165174
.env("RUSTUP_TOOLCHAIN", "test-toolchain")
166175
.env("RUSTUP_HOME", &rustup_home)
167176
.env("PATH", &path)
@@ -179,6 +188,7 @@ real rustc running
179188
p.build_dir().rm_rf();
180189

181190
p.cargo("check")
191+
.env("RUSTUP_TOOLCHAIN_SOURCE", "default")
182192
.env("RUSTUP_TOOLCHAIN", "test-toolchain")
183193
.env("RUSTUP_HOME", &rustup_home)
184194
.env("PATH", &path)
@@ -249,6 +259,7 @@ fn custom_calls_other_cargo() {
249259
// Set these to simulate what would happen when running under rustup.
250260
// We want to make sure that cargo-custom does not try to use the
251261
// rustup proxies.
262+
.env("RUSTUP_TOOLCHAIN_SOURCE", "default")
252263
.env("RUSTUP_TOOLCHAIN", "test-toolchain")
253264
.env("RUSTUP_HOME", &rustup_home)
254265
.with_stderr_data(str![[r#"

0 commit comments

Comments
 (0)