Skip to content

Commit 1f66f90

Browse files
committed
Rust: fix parallel execution of tests using the nightly toolchain
Since we dropped checked in toolchain files for tests requiring nightly, the `setup.sh` script was not doing its job of setting up the toolchains and the `rust-src` component, occasionally leading to test failures.
1 parent 1e68a7e commit 1f66f90

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

rust/extractor/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ codeql_rust_binary(
77
name = "extractor",
88
srcs = glob(["src/**/*.rs"]),
99
aliases = aliases(),
10-
compile_data = ["src/qltest_cargo.mustache"],
10+
compile_data = [
11+
"src/qltest_cargo.mustache",
12+
"src/nightly-toolchain/rust-toolchain.toml",
13+
],
1114
proc_macro_deps = all_crate_deps(
1215
proc_macro = True,
1316
) + [
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly-2025-06-01"
3+
components = [ "rust-src" ]

rust/extractor/src/qltest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::process::Command;
99
use tracing::info;
1010

1111
const EDITION: &str = "2021";
12-
const NIGHTLY: &str = "nightly-2025-06-01";
1312

1413
fn dump_lib() -> anyhow::Result<()> {
1514
let path_iterator = glob("*.rs").context("globbing test sources")?;
@@ -76,7 +75,7 @@ fn dump_cargo_manifest(dependencies: &[String]) -> anyhow::Result<()> {
7675
fn dump_nightly_toolchain() -> anyhow::Result<()> {
7776
fs::write(
7877
"rust-toolchain.toml",
79-
format!("[toolchain]\nchannel = \"{NIGHTLY}\"\n"),
78+
include_str!("nightly-toolchain/rust-toolchain.toml"),
8079
)
8180
.context("writing rust-toolchain.toml")?;
8281
Ok(())

rust/ql/test/setup.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ set -euo pipefail
55
# This script is run by the CI to set up the test environment for the Rust QL tests
66
# We run this as rustup is not meant to be run in parallel, and will this setup will be run by rust-analyzer in the
77
# parallel QL tests unless we do the setup prior to launching the tests.
8-
# We do this for each `rust-toolchain.toml` we use in the tests (and the root one in `rust` last, so it becomes the
9-
# default).
108

9+
# no need to install rust-src explicitly, it's listed in both toolchains
1110
cd "$(dirname "$0")"
12-
13-
find . -name rust-toolchain.toml \
14-
-execdir rustup install \; \
15-
-execdir rustup component add rust-src \;
16-
17-
# no to install rust-src explicitly, it's listed in ql/rust/rust-toolchain.toml
11+
pushd ../../extractor/src/nightly-toolchain
12+
rustup install
13+
popd
14+
# this needs to be last to set the default toolchain
1815
rustup install

0 commit comments

Comments
 (0)