diff options
| author | Pietro Albini <pietro.albini@ferrous-systems.com> | 2024-06-14 12:02:45 +0200 |
|---|---|---|
| committer | Pietro Albini <pietro.albini@ferrous-systems.com> | 2024-06-14 13:00:49 +0200 |
| commit | d3f1618a73d3f14bfdd28d62c1d933755ccbad3e (patch) | |
| tree | df16b7c3b487c254918cfae228578118cef95b39 | |
| parent | bdb1b7f5d9715cc96cb437134eff93fa229defd1 (diff) | |
| download | rust-d3f1618a73d3f14bfdd28d62c1d933755ccbad3e.tar.gz rust-d3f1618a73d3f14bfdd28d62c1d933755ccbad3e.zip | |
fix python bootstrap tests requiring a downloaded stage0
| -rw-r--r-- | src/bootstrap/bootstrap_test.py | 19 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index 6da410ed2f2..706f2c5bf07 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -138,6 +138,25 @@ class BuildBootstrap(unittest.TestCase): if env is None: env = {} + # This test ends up invoking build_bootstrap_cmd, which searches for + # the Cargo binary and errors out if it cannot be found. This is not a + # problem in most cases, but there is a scenario where it would cause + # the test to fail. + # + # When a custom local Cargo is configured in config.toml (with the + # build.cargo setting), no Cargo is downloaded to any location known by + # bootstrap, and bootstrap relies on that setting to find it. + # + # In this test though we are not using the config.toml of the caller: + # we are generating a blank one instead. If we don't set build.cargo in + # it, the test will have no way to find Cargo, failing the test. + cargo_bin = os.environ.get("BOOTSTRAP_TEST_CARGO_BIN") + if cargo_bin is not None: + configure_args += ["--set", "build.cargo=" + cargo_bin] + rustc_bin = os.environ.get("BOOTSTRAP_TEST_RUSTC_BIN") + if rustc_bin is not None: + configure_args += ["--set", "build.rustc=" + rustc_bin] + env = env.copy() env["PATH"] = os.environ["PATH"] diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 29cd90222b2..22a3f1efa29 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3040,6 +3040,8 @@ impl Step for Bootstrap { .args(["-m", "unittest", "bootstrap_test.py"]) .env("BUILD_DIR", &builder.out) .env("BUILD_PLATFORM", builder.build.build.triple) + .env("BOOTSTRAP_TEST_RUSTC_BIN", &builder.initial_rustc) + .env("BOOTSTRAP_TEST_CARGO_BIN", &builder.initial_cargo) .current_dir(builder.src.join("src/bootstrap/")); // NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible. // Use `python -m unittest` manually if you want to pass arguments. |
