Skip to content

Commit cc33b79

Browse files
redsun82Copilot
andcommitted
Rust: pin integration test toolchain to 1.94.1
Pin `RUSTUP_TOOLCHAIN` in rust integration tests to the version from `rust-toolchain.toml`, so that tests are not affected by the Rust version pre-installed on runner images. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2886127 commit cc33b79

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

rust/ql/integration-tests/conftest.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
import os
12
import pytest
23
import json
34
import commands
45
import pathlib
56
import tomllib
67

8+
_toolchain_file = pathlib.Path(__file__).resolve().parent.parent / "test" / "rust-toolchain.toml"
9+
_toolchain_channel = tomllib.loads(_toolchain_file.read_text())["toolchain"]["channel"]
10+
11+
12+
@pytest.fixture(autouse=True)
13+
def _pin_rust_toolchain(environment):
14+
"""Pin the Rust toolchain to the version specified in ql/test/rust-toolchain.toml.
15+
16+
Integration tests run from temporary directories, so they don't pick up the
17+
rust-toolchain.toml file via rustup's file-based resolution. Setting
18+
RUSTUP_TOOLCHAIN ensures a consistent version regardless of the runner image.
19+
"""
20+
os.environ["RUSTUP_TOOLCHAIN"] = _toolchain_channel
21+
722

823
@pytest.fixture(params=[2018, 2021, 2024])
924
def rust_edition(request):
@@ -33,7 +48,7 @@ def update(file):
3348

3449
@pytest.fixture(scope="session")
3550
def rust_sysroot_src() -> str:
36-
rust_sysroot = pathlib.Path(commands.run("rustc --print sysroot", _capture=True))
51+
rust_sysroot = pathlib.Path(commands.run(f"rustc +{_toolchain_channel} --print sysroot", _capture=True))
3752
ret = rust_sysroot.joinpath("lib", "rustlib", "src", "rust", "library")
3853
assert ret.exists()
3954
return str(ret)

rust/ql/test/rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# IMPORTANT: this can also have an impact on QL test results
33

44
[toolchain]
5-
channel = "1.90"
5+
channel = "1.94.1"
66
profile = "minimal"
77
components = [ "rust-src" ]

0 commit comments

Comments
 (0)