about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-05-25 22:15:18 +0200
committerGitHub <noreply@github.com>2024-05-25 22:15:18 +0200
commit64730a1632f4b13923ee32782cd4718613aea9a3 (patch)
tree93d285cc9bb6436d8fc0cd951e49e65127048dbb
parent80aea305d388bd39a1bb5d92212de8fbde100c97 (diff)
parent5888de8cbe20589846f459bb35bfa26206c81e50 (diff)
downloadrust-64730a1632f4b13923ee32782cd4718613aea9a3.tar.gz
rust-64730a1632f4b13923ee32782cd4718613aea9a3.zip
Rollup merge of #125472 - erikdesjardins:component, r=clubby789
tidy: validate LLVM component names in tests

LLVM component names are not immediately obvious (they usually omit any suffixes on the target arch name), and if they're incorrect, the test will silently never run.

This happened [here](https://github.com/rust-lang/rust/pull/125220#discussion_r1612626002), and it would be nice to prevent it.
-rw-r--r--src/tools/tidy/src/target_specific_tests.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs
index c876aae494d..5a402f3cc60 100644
--- a/src/tools/tidy/src/target_specific_tests.rs
+++ b/src/tools/tidy/src/target_specific_tests.rs
@@ -10,6 +10,25 @@ use crate::walk::filter_not_rust;
 const LLVM_COMPONENTS_HEADER: &str = "needs-llvm-components:";
 const COMPILE_FLAGS_HEADER: &str = "compile-flags:";
 
+const KNOWN_LLVM_COMPONENTS: &[&str] = &[
+    "aarch64",
+    "arm",
+    "avr",
+    "bpf",
+    "hexagon",
+    "loongarch",
+    "m68k",
+    "mips",
+    "msp430",
+    "nvptx",
+    "powerpc",
+    "riscv",
+    "sparc",
+    "systemz",
+    "webassembly",
+    "x86",
+];
+
 #[derive(Default, Debug)]
 struct RevisionInfo<'a> {
     target_arch: Option<&'a str>,
@@ -68,6 +87,17 @@ pub fn check(path: &Path, bad: &mut bool) {
                     // gathered.
                 }
             }
+            if let Some(llvm_components) = llvm_components {
+                for component in llvm_components {
+                    if !KNOWN_LLVM_COMPONENTS.contains(component) {
+                        eprintln!(
+                            "{}: revision {} specifies unknown LLVM component `{}`",
+                            file, rev, component
+                        );
+                        *bad = true;
+                    }
+                }
+            }
         }
     });
 }