Skip to content

Commit

Permalink
Rollup merge of #124137 - tgross35:testsuite-multi-rev-regex, r=jieyouxu
Browse files Browse the repository at this point in the history
Match hyphen in multi-revision comment matchers

Currently, the matcher `//[rev-foo,rev-bar]~` does not get selected by the regex. Change the matcher to include `-`.
  • Loading branch information
matthiaskrgr authored Apr 20, 2024
2 parents ff9a0b1 + 282488c commit f58ef08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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());
}

0 comments on commit f58ef08

Please sign in to comment.