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

Match hyphen in multi-revision comment matchers #124137

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/tools/compiletest/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn parse_expected(
// //[rev1]~
// //[rev1,rev2]~^^
static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap());

let captures = RE.captures(line)?;

Expand Down Expand Up @@ -178,3 +178,6 @@ fn parse_expected(
);
Some((which, Error { line_num, kind, msg }))
}

#[cfg(test)]
mod tests;
12 changes: 12 additions & 0 deletions src/tools/compiletest/src/errors/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use super::*;

#[test]
fn test_parse_expected_matching() {
// Ensure that we correctly extract expected revisions
let d1 = "//[rev1,rev2]~^ ERROR foo";
let d2 = "//[rev1,rev2-foo]~^ ERROR foo";
assert!(parse_expected(None, 1, d1, Some("rev1")).is_some());
assert!(parse_expected(None, 1, d1, Some("rev2")).is_some());
assert!(parse_expected(None, 1, d2, Some("rev1")).is_some());
assert!(parse_expected(None, 1, d2, Some("rev2-foo")).is_some());
}
Loading