Skip to content

Commit 5ec1026

Browse files
redsun82Copilot
andcommitted
Rust: pin integration test toolchain to 1.94.1
Write a `rust-toolchain.toml` into each integration test's working directory so that tests use a consistent Rust version regardless of what is pre-installed on the runner image. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2886127 commit 5ec1026

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

rust/ql/integration-tests/conftest.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
import pathlib
55
import tomllib
66

7+
_PINNED_TOOLCHAIN = "1.94.1"
8+
9+
10+
@pytest.fixture(autouse=True)
11+
def _pin_rust_toolchain(cwd):
12+
"""Pin the Rust toolchain for integration tests.
13+
14+
Integration tests run from temporary directories, so they don't pick up
15+
rust-toolchain.toml via rustup's file-based resolution. Writing the file
16+
into the test's working directory ensures a consistent toolchain version
17+
regardless of what is pre-installed on the runner image.
18+
"""
19+
(cwd / "rust-toolchain.toml").write_text(
20+
f'[toolchain]\nchannel = "{_PINNED_TOOLCHAIN}"\ncomponents = ["rust-src"]\n'
21+
)
22+
723

824
@pytest.fixture(params=[2018, 2021, 2024])
925
def rust_edition(request):
@@ -33,7 +49,8 @@ def update(file):
3349

3450
@pytest.fixture(scope="session")
3551
def rust_sysroot_src() -> str:
36-
rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True))
52+
commands.run(f"rustup component add rust-src --toolchain {_PINNED_TOOLCHAIN}")
53+
rust_sysroot = pathlib.Path(commands.run(f"rustc +{_PINNED_TOOLCHAIN} --print sysroot", _capture=True))
3754
ret = rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library")
3855
assert ret.exists()
3956
return str(ret)

0 commit comments

Comments
 (0)