Skip to content

Commit

Permalink
tests: Allow to run tests in parallel even if the LLVM tool is not in…
Browse files Browse the repository at this point in the history
…stalled
  • Loading branch information
taiki-e committed Sep 29, 2023
1 parent ca62606 commit 1ffc580
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
with:
persist-credentials: false
- name: Install Rust
run: rustup toolchain add ${{ matrix.rust }} --no-self-update --component llvm-tools-preview && rustup default ${{ matrix.rust }}
run: rustup toolchain add ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
- run: rustup toolchain add nightly --no-self-update
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
Expand Down
10 changes: 10 additions & 0 deletions tests/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
mem,
path::{Path, PathBuf},
process::{Command, ExitStatus, Stdio},
sync::OnceLock,
};

use anyhow::{Context as _, Result};
Expand All @@ -19,7 +20,16 @@ pub fn fixtures_path() -> &'static Utf8Path {
Utf8Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/fixtures"))
}

fn ensure_llvm_tools_installed() {
static TEST_VERSION: OnceLock<()> = OnceLock::new();
TEST_VERSION.get_or_init(|| {
// Install component first to avoid component installation conflicts.
let _ = Command::new("rustup").args(["component", "add", "llvm-tools-preview"]).output();
});
}

pub fn cargo_llvm_cov(subcommand: &str) -> Command {
ensure_llvm_tools_installed();
let mut cmd = Command::new(env!("CARGO_BIN_EXE_cargo-llvm-cov"));
cmd.arg("llvm-cov");
if !subcommand.is_empty() {
Expand Down

0 comments on commit 1ffc580

Please sign in to comment.