Skip to content

Commit d3f1618

Browse files
committed
fix python bootstrap tests requiring a downloaded stage0
1 parent bdb1b7f commit d3f1618

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/bootstrap/bootstrap_test.py

+19
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ def build_args(self, configure_args=None, args=None, env=None):
138138
if env is None:
139139
env = {}
140140

141+
# This test ends up invoking build_bootstrap_cmd, which searches for
142+
# the Cargo binary and errors out if it cannot be found. This is not a
143+
# problem in most cases, but there is a scenario where it would cause
144+
# the test to fail.
145+
#
146+
# When a custom local Cargo is configured in config.toml (with the
147+
# build.cargo setting), no Cargo is downloaded to any location known by
148+
# bootstrap, and bootstrap relies on that setting to find it.
149+
#
150+
# In this test though we are not using the config.toml of the caller:
151+
# we are generating a blank one instead. If we don't set build.cargo in
152+
# it, the test will have no way to find Cargo, failing the test.
153+
cargo_bin = os.environ.get("BOOTSTRAP_TEST_CARGO_BIN")
154+
if cargo_bin is not None:
155+
configure_args += ["--set", "build.cargo=" + cargo_bin]
156+
rustc_bin = os.environ.get("BOOTSTRAP_TEST_RUSTC_BIN")
157+
if rustc_bin is not None:
158+
configure_args += ["--set", "build.rustc=" + rustc_bin]
159+
141160
env = env.copy()
142161
env["PATH"] = os.environ["PATH"]
143162

src/bootstrap/src/core/build_steps/test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,8 @@ impl Step for Bootstrap {
30403040
.args(["-m", "unittest", "bootstrap_test.py"])
30413041
.env("BUILD_DIR", &builder.out)
30423042
.env("BUILD_PLATFORM", builder.build.build.triple)
3043+
.env("BOOTSTRAP_TEST_RUSTC_BIN", &builder.initial_rustc)
3044+
.env("BOOTSTRAP_TEST_CARGO_BIN", &builder.initial_cargo)
30433045
.current_dir(builder.src.join("src/bootstrap/"));
30443046
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
30453047
// Use `python -m unittest` manually if you want to pass arguments.

0 commit comments

Comments
 (0)