Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement "only-<platforms>" for test headers #47487

Merged
merged 4 commits into from
Jan 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl EarlyProps {
props.ignore =
props.ignore ||
config.parse_cfg_name_directive(ln, "ignore") ||
(config.parse_cfg_prefix(ln, "only") &&
!config.parse_cfg_name_directive(ln, "only")) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to call parse_cfg_prefix here but not for ignore? What makes only special?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks is there any //only-<> specification present and if so, does it matches with current platform.

  1. If there exists a //only-<> and the platform does not matches, this should be skipped
  2. If there exists a //only-<> and the platform does match, this should not be skipped

For ignore, we don't care if any other //ignore-<> exists. Like platform 'bar' won't care of //ignore- but it should care if //only- exists.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. Thanks! Can we put that into a (short) comment in the code perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure that will be helpful. I will add that. I am also not sure what should interactions between //only-<> and //ignore-<> should result into. There can be some interesting cases there.

ignore_gdb(config, ln) ||
ignore_lldb(config, ln) ||
ignore_llvm(config, ln);
Expand Down Expand Up @@ -564,6 +566,17 @@ impl Config {
}
}

fn parse_cfg_prefix(&self, line: &str, prefix: &str) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename this to something like has_cfg_prefix? It's not really parsing right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Can you point what's wrong with parsing? Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing wrong, just that a function returning bool seems like it shouldn't be called a parse_* function since it's not actually returning the results of the parsing, so to speak. I don't feel too strongly about this but has_cfg_prefix seems clearer to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood, I will update the function name.

// 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.
if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') {
true
} else {
false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if x { true } else { false } can simply be x...

}

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