Rust: pin integration test toolchain to 1.94.1#21763
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Pins the Rust toolchain used by the Rust integration tests to the version declared in rust/ql/test/rust-toolchain.toml, aiming to make CI test behavior independent of whatever Rust is preinstalled on the runner image.
Changes:
- Bump Rust test toolchain channel from
1.90to1.94.1. - Add an autouse pytest fixture to set
RUSTUP_TOOLCHAINbased on the sharedrust-toolchain.toml. - Update sysroot discovery to call
rustc +{channel} --print sysrootto ensure the pinned toolchain is used.
Show a summary per file
| File | Description |
|---|---|
| rust/ql/test/rust-toolchain.toml | Updates the pinned Rust channel used by Rust QL tests. |
| rust/ql/integration-tests/conftest.py | Reads the pinned channel and attempts to enforce it for integration tests via env var + rustc +toolchain. |
Copilot's findings
Comments suppressed due to low confidence (1)
rust/ql/integration-tests/conftest.py:20
- This autouse fixture mutates
os.environbut never restores the previous value. Since environment variables are process-global, this can leak into later tests outsiderust/ql/integration-testswhen running a larger pytest suite. Prefer setting the variable viamonkeypatch.setenv(...)(auto-restored), or implement ayieldfixture that restores/deletesRUSTUP_TOOLCHAINafterwards (potentially withscope="session"if you only need to set it once).
@pytest.fixture(autouse=True)
def _pin_rust_toolchain(environment):
"""Pin the Rust toolchain to the version specified in ql/test/rust-toolchain.toml.
Integration tests run from temporary directories, so they don't pick up the
rust-toolchain.toml file via rustup's file-based resolution. Setting
RUSTUP_TOOLCHAIN ensures a consistent version regardless of the runner image.
"""
os.environ["RUSTUP_TOOLCHAIN"] = _toolchain_channel
- Files reviewed: 2/2 changed files
- Comments generated: 1
9b0963a to
e0e279a
Compare
e0e279a to
ad23242
Compare
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>
ad23242 to
ba64983
Compare
Contributor
Author
|
No longer needed — toolchain pinning will be handled entirely in the semmle-code prepare action via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pin the Rust toolchain used by integration tests to 1.94.1 to prevent breakage from runner images that ship newer versions.
Changes
rust/ql/integration-tests/conftest.py:_pin_rust_toolchainfixture that writes arust-toolchain.toml(pinned to 1.94.1 withrust-srccomponent) into each test's working directoryrust_sysroot_srcto userustc +1.94.1and explicitly ensurerust-srcis installedNo changes to
rust/ql/test/rust-toolchain.toml— QL language tests are unaffected.