Skip to content

Commit fd075c6

Browse files
committed
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 is a fix for issues rust-lang#33581 and rust-lang#47459.
1 parent 79a521b commit fd075c6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ impl EarlyProps {
4444
props.ignore =
4545
props.ignore ||
4646
config.parse_cfg_name_directive(ln, "ignore") ||
47+
(config.parse_cfg_prefix(ln, "only") &&
48+
!config.parse_cfg_name_directive(ln, "only")) ||
4749
ignore_gdb(config, ln) ||
4850
ignore_lldb(config, ln) ||
4951
ignore_llvm(config, ln);
@@ -564,6 +566,17 @@ impl Config {
564566
}
565567
}
566568

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

0 commit comments

Comments
 (0)