Skip to content

Commit aed27c5

Browse files
committed
set the correct rustc and cargo even for tests invoking parse_inner
1 parent 198c809 commit aed27c5

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/bootstrap/src/core/config/config.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1189,19 +1189,7 @@ impl Config {
11891189
pub fn parse(args: &[String]) -> Config {
11901190
#[cfg(test)]
11911191
fn get_toml(_: &Path) -> TomlConfig {
1192-
let mut default = TomlConfig::default();
1193-
1194-
// When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
1195-
// same ones used to call the tests. If we don't do that, bootstrap will use its own
1196-
// detection logic to find a suitable rustc and Cargo, which doesn't work when the
1197-
// caller is specìfying a custom local rustc or Cargo in their config.toml.
1198-
default.build = Some(Build {
1199-
rustc: std::env::var_os("RUSTC").map(|v| v.into()),
1200-
cargo: std::env::var_os("CARGO").map(|v| v.into()),
1201-
..Build::default()
1202-
});
1203-
1204-
default
1192+
TomlConfig::default()
12051193
}
12061194

12071195
#[cfg(not(test))]
@@ -1341,6 +1329,18 @@ impl Config {
13411329
TomlConfig::default()
13421330
};
13431331

1332+
#[cfg(test)]
1333+
{
1334+
// When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
1335+
// same ones used to call the tests (if custom ones are not defined in the toml). If we
1336+
// don't do that, bootstrap will use its own detection logic to find a suitable rustc
1337+
// and Cargo, which doesn't work when the caller is specìfying a custom local rustc or
1338+
// Cargo in their config.toml.
1339+
let build = toml.build.get_or_insert_default();
1340+
build.rustc = build.rustc.or(std::env::var_os("RUSTC").into());
1341+
build.cargo = build.cargo.or(std::env::var_os("CARGO").into());
1342+
}
1343+
13441344
if let Some(include) = &toml.profile {
13451345
// Allows creating alias for profile names, allowing
13461346
// profiles to be renamed while maintaining back compatibility

0 commit comments

Comments
 (0)