Skip to content

Commit

Permalink
tidy: validate LLVM component names in tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
erikdesjardins committed May 24, 2024
1 parent 8679004 commit 5888de8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/tools/tidy/src/target_specific_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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;
}
}
}
}
});
}

0 comments on commit 5888de8

Please sign in to comment.