about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-07-21 11:51:36 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-07-22 16:43:03 +0200
commit6bfa00816d7e4dcb0aee9fe547bc75dfe59dc613 (patch)
tree467ead54e33d50e7f82ffc75f7237267858476b5 /src
parenta27f3e3fd1e4d16160f8885b6b06665b5319f56c (diff)
downloadrust-6bfa00816d7e4dcb0aee9fe547bc75dfe59dc613.tar.gz
rust-6bfa00816d7e4dcb0aee9fe547bc75dfe59dc613.zip
Only run `tests/assembly-*` and `tests/codegen-*` tests if they match the current codegen backend
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/common.rs4
-rw-r--r--src/tools/compiletest/src/lib.rs19
2 files changed, 20 insertions, 3 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 12084fa0b15..aceae3e3a3b 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -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",
diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs
index 41bed8ed8a0..c712185733c 100644
--- a/src/tools/compiletest/src/lib.rs
+++ b/src/tools/compiletest/src/lib.rs
@@ -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();