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

Revise revisions #33

Merged
merged 16 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ their command specifies, or the test will fail without even being run.
* `//@error-pattern: XXX` make sure the stderr output contains `XXX`
* `//@revisions: XXX YYY` runs the test once for each space separated name in the list
* emits one stderr file per revision
* `//~` comments can be restricted to specific revisions by adding the revision name before the `~` in square brackets: `//[XXX]~`
* `//~` comments can be restricted to specific revisions by adding the revision name after the `~` in square brackets: `//~[XXX]`
* `//@` comments can be restricted to specific revisions by adding the revision name after the `@` in square brackets: `//@[XXX]`
* Note that you cannot add revisions to the `revisions` command.
* `//@compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver
* you can specify this multiple times, and all the flags will accumulate
* `//@rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution.
Expand Down
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,21 @@ fn check_annotations(
}

let filter = |msgs: Vec<Message>, errors: &mut Vec<_>| -> Vec<_> {
let mut error = |_| {
errors.push(Error::InvalidComment {
msg: "`require_annotations_for_level` specified twice for same revision".into(),
line: 0,
})
};
msgs.into_iter()
.filter(|msg| {
msg.level
>= comments
.find_one_for_revision(revision, |r| r.require_annotations_for_level, |_| errors.push(Error::InvalidComment { msg: "`require_annotations_for_level` specified twice for same revision".into(), line: 0 }))
.find_one_for_revision(
revision,
|r| r.require_annotations_for_level,
&mut error,
)
.unwrap_or(lowest_annotation_level)
})
.collect()
Expand Down
19 changes: 8 additions & 11 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,14 @@ impl CommentParser<Comments> {
}
};

match command {
"revisions" => {
self.check(
revisions.is_empty(),
"cannot declare revisions under a revision",
);
self.check(self.revisions.is_none(), "cannot specify `revisions` twice");
self.revisions = Some(args.split_whitespace().map(|s| s.to_string()).collect());
return;
}
_ => {}
if command == "revisions" {
self.check(
revisions.is_empty(),
"cannot declare revisions under a revision",
);
self.check(self.revisions.is_none(), "cannot specify `revisions` twice");
self.revisions = Some(args.split_whitespace().map(|s| s.to_string()).collect());
return;
}
self.revisioned(revisions, |this| this.parse_command(command, args));
}
Expand Down