Only run tests/assembly-* and tests/codegen-* tests if they match the current codegen backend

This commit is contained in:
Guillaume Gomez 2025-07-21 11:51:36 +02:00
parent a27f3e3fd1
commit 6bfa00816d
2 changed files with 20 additions and 3 deletions

View file

@ -57,8 +57,8 @@ impl TestMode {
string_enum! {
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum TestSuite {
Assembly => "assembly",
Codegen => "codegen",
AssemblyLlvm => "assembly-llvm",
CodegenLlvm => "codegen-llvm",
CodegenUnits => "codegen-units",
Coverage => "coverage",
CoverageRunRustdoc => "coverage-run-rustdoc",

View file

@ -31,7 +31,7 @@ use std::time::SystemTime;
use std::{env, fs, vec};
use build_helper::git::{get_git_modified_files, get_git_untracked_files};
use camino::{Utf8Path, Utf8PathBuf};
use camino::{Utf8Component, Utf8Path, Utf8PathBuf};
use getopts::Options;
use rayon::iter::{ParallelBridge, ParallelIterator};
use tracing::debug;
@ -799,6 +799,23 @@ fn collect_tests_from_dir(
return Ok(TestCollector::new());
}
let mut components = dir.components().rev();
if let Some(Utf8Component::Normal(last)) = components.next()
&& let Some(("assembly" | "codegen", backend)) = last.split_once('-')
&& let Some(Utf8Component::Normal(parent)) = components.next()
&& parent == "tests"
&& let Ok(backend) = CodegenBackend::try_from(backend)
&& backend != cx.config.codegen_backend
{
// We ignore asm tests which don't match the current codegen backend.
warning!(
"Ignoring tests in `{dir}` because they don't match the configured codegen \
backend (`{}`)",
cx.config.codegen_backend.as_str(),
);
return Ok(TestCollector::new());
}
// For run-make tests, a "test file" is actually a directory that contains an `rmake.rs`.
if cx.config.mode == TestMode::RunMake {
let mut collector = TestCollector::new();