Skip to content

Commit

Permalink
Rollup merge of rust-lang#47487 - Pulkit07:foo, r=kennytm
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kennytm authored Jan 17, 2018
2 parents eaa7a1f + bd70f0f commit ee636ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ impl EarlyProps {
iter_header(testfile,
None,
&mut |ln| {
// we should check if any only-<platform> exists and if it exists
// and does not matches the current platform, skip the test
props.ignore =
props.ignore ||
config.parse_cfg_name_directive(ln, "ignore") ||
(config.has_cfg_prefix(ln, "only") &&
!config.parse_cfg_name_directive(ln, "only")) ||
ignore_gdb(config, ln) ||
ignore_lldb(config, ln) ||
ignore_llvm(config, ln);
Expand Down Expand Up @@ -564,6 +568,13 @@ impl Config {
}
}

fn has_cfg_prefix(&self, line: &str, prefix: &str) -> bool {
// returns whether this line contains this prefix or not. For prefix
// "ignore", returns true if line says "ignore-x86_64", "ignore-arch",
// "ignore-andorid" etc.
line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-')
}

fn parse_name_directive(&self, line: &str, directive: &str) -> bool {
// Ensure the directive is a whole word. Do not match "ignore-x86" when
// the line says "ignore-x86_64".
Expand Down

0 comments on commit ee636ed

Please sign in to comment.