Skip to content

Commit 5e1f442

Browse files
authored
Rollup merge of rust-lang#47487 - Pulkit07:foo, r=kennytm
implement "only-<platforms>" for test headers This patch implements "only-<platforms>" for tests headers using which one can specify just the platforms on which the test should run rather than listing all the platforms to ignore using "ignore-<platforms>". This fixes rust-lang#33581 and fixes rust-lang#47459.
2 parents 3501095 + bd70f0f commit 5e1f442

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ impl EarlyProps {
4141
iter_header(testfile,
4242
None,
4343
&mut |ln| {
44+
// we should check if any only-<platform> exists and if it exists
45+
// and does not matches the current platform, skip the test
4446
props.ignore =
4547
props.ignore ||
4648
config.parse_cfg_name_directive(ln, "ignore") ||
49+
(config.has_cfg_prefix(ln, "only") &&
50+
!config.parse_cfg_name_directive(ln, "only")) ||
4751
ignore_gdb(config, ln) ||
4852
ignore_lldb(config, ln) ||
4953
ignore_llvm(config, ln);
@@ -564,6 +568,13 @@ impl Config {
564568
}
565569
}
566570

571+
fn has_cfg_prefix(&self, line: &str, prefix: &str) -> bool {
572+
// returns whether this line contains this prefix or not. For prefix
573+
// "ignore", returns true if line says "ignore-x86_64", "ignore-arch",
574+
// "ignore-andorid" etc.
575+
line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-')
576+
}
577+
567578
fn parse_name_directive(&self, line: &str, directive: &str) -> bool {
568579
// Ensure the directive is a whole word. Do not match "ignore-x86" when
569580
// the line says "ignore-x86_64".

0 commit comments

Comments
 (0)