Skip to content

Commit 64730a1

Browse files
authored
Rollup merge of rust-lang#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](rust-lang#125220 (comment)), and it would be nice to prevent it.
2 parents 80aea30 + 5888de8 commit 64730a1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tools/tidy/src/target_specific_tests.rs

+30
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,25 @@ use crate::walk::filter_not_rust;
1010
const LLVM_COMPONENTS_HEADER: &str = "needs-llvm-components:";
1111
const COMPILE_FLAGS_HEADER: &str = "compile-flags:";
1212

13+
const KNOWN_LLVM_COMPONENTS: &[&str] = &[
14+
"aarch64",
15+
"arm",
16+
"avr",
17+
"bpf",
18+
"hexagon",
19+
"loongarch",
20+
"m68k",
21+
"mips",
22+
"msp430",
23+
"nvptx",
24+
"powerpc",
25+
"riscv",
26+
"sparc",
27+
"systemz",
28+
"webassembly",
29+
"x86",
30+
];
31+
1332
#[derive(Default, Debug)]
1433
struct RevisionInfo<'a> {
1534
target_arch: Option<&'a str>,
@@ -68,6 +87,17 @@ pub fn check(path: &Path, bad: &mut bool) {
6887
// gathered.
6988
}
7089
}
90+
if let Some(llvm_components) = llvm_components {
91+
for component in llvm_components {
92+
if !KNOWN_LLVM_COMPONENTS.contains(component) {
93+
eprintln!(
94+
"{}: revision {} specifies unknown LLVM component `{}`",
95+
file, rev, component
96+
);
97+
*bad = true;
98+
}
99+
}
100+
}
71101
}
72102
});
73103
}

0 commit comments

Comments
 (0)