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

Allow whitespaces in revision flags #69205

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Changes from all commits
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
11 changes: 2 additions & 9 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,6 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn

let comment = if testfile.to_string_lossy().ends_with(".rs") { "//" } else { "#" };

// FIXME: would be nice to allow some whitespace between comment and brace :)
// It took me like 2 days to debug why compile-flags weren’t taken into account for my test :)
let comment_with_brace = comment.to_string() + "[";

let mut rdr = BufReader::new(rdr);
let mut ln = String::new();

Expand All @@ -650,7 +646,7 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
let ln = ln.trim();
if ln.starts_with("fn") || ln.starts_with("mod") {
return;
} else if ln.starts_with(&comment_with_brace) {
} else if ln.starts_with(comment) && ln[comment.len()..].trim_start().starts_with('[') {
// A comment like `//[foo]` is specific to revision `foo`
if let Some(close_brace) = ln.find(']') {
let open_brace = ln.find('[').unwrap();
Expand All @@ -663,10 +659,7 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
it(ln[(close_brace + 1)..].trim_start());
}
} else {
panic!(
"malformed condition directive: expected `{}foo]`, found `{}`",
comment_with_brace, ln
)
panic!("malformed condition directive: expected `{}[foo]`, found `{}`", comment, ln)
}
} else if ln.starts_with(comment) {
it(ln[comment.len()..].trim_start());
Expand Down