Skip to content

Rust: fix parallel execution of tests using the nightly toolchain #19876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rust/extractor/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ codeql_rust_binary(
name = "extractor",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(),
compile_data = ["src/qltest_cargo.mustache"],
compile_data = [
"src/qltest_cargo.mustache",
"src/nightly-toolchain/rust-toolchain.toml",
],
proc_macro_deps = all_crate_deps(
proc_macro = True,
) + [
Expand Down
3 changes: 3 additions & 0 deletions rust/extractor/src/nightly-toolchain/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2025-06-01"
components = [ "rust-src" ]
3 changes: 1 addition & 2 deletions rust/extractor/src/qltest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::process::Command;
use tracing::info;

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

fn dump_lib() -> anyhow::Result<()> {
let path_iterator = glob("*.rs").context("globbing test sources")?;
Expand Down Expand Up @@ -76,7 +75,7 @@ fn dump_cargo_manifest(dependencies: &[String]) -> anyhow::Result<()> {
fn dump_nightly_toolchain() -> anyhow::Result<()> {
fs::write(
"rust-toolchain.toml",
format!("[toolchain]\nchannel = \"{NIGHTLY}\"\n"),
include_str!("nightly-toolchain/rust-toolchain.toml"),
)
.context("writing rust-toolchain.toml")?;
Ok(())
Expand Down
13 changes: 5 additions & 8 deletions rust/ql/test/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ set -euo pipefail
# This script is run by the CI to set up the test environment for the Rust QL tests
# 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
# parallel QL tests unless we do the setup prior to launching the tests.
# We do this for each `rust-toolchain.toml` we use in the tests (and the root one in `rust` last, so it becomes the
# default).

# no need to install rust-src explicitly, it's listed in both toolchains
cd "$(dirname "$0")"

find . -name rust-toolchain.toml \
-execdir rustup install \; \
-execdir rustup component add rust-src \;

# no to install rust-src explicitly, it's listed in ql/rust/rust-toolchain.toml
pushd ../../extractor/src/nightly-toolchain
rustup install
popd
# this needs to be last to set the default toolchain
rustup install