about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/bootstrap/src/core/config/config.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 36b44d0169c..6664c5b451c 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -1189,7 +1189,19 @@ impl Config {
     pub fn parse(args: &[String]) -> Config {
         #[cfg(test)]
         fn get_toml(_: &Path) -> TomlConfig {
-            TomlConfig::default()
+            let mut default = TomlConfig::default();
+
+            // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
+            // same ones used to call the tests. If we don't do that, bootstrap will use its own
+            // detection logic to find a suitable rustc and Cargo, which doesn't work when the
+            // caller is specìfying a custom local rustc or Cargo in their config.toml.
+            default.build = Some(Build {
+                rustc: std::env::var_os("RUSTC").map(|v| v.into()),
+                cargo: std::env::var_os("CARGO").map(|v| v.into()),
+                ..Build::default()
+            });
+
+            default
         }
 
         #[cfg(not(test))]