Merge pull request #19876 from github/redsun82/rust-qltest-setup-nightly-toolchain

Rust: fix parallel execution of tests using the nightly toolchain
This commit is contained in:
Paolo Tranquilli
2025-06-25 14:30:22 +02:00
committed by GitHub
4 changed files with 13 additions and 11 deletions

View File

@@ -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,
) + [

View File

@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2025-06-01"
components = [ "rust-src" ]

View File

@@ -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")?;
@@ -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(())

View File

@@ -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