Skip to content

Commit

Permalink
Match hyphen in multi-revision comment matchers
Browse files Browse the repository at this point in the history
Currently, the matcher `//[rev-foo,rev-bar]~` does not get selected by
the regex. Change the matcher to also match strings that contain a `-`.h
  • Loading branch information
tgross35 committed Apr 19, 2024
1 parent d1a0fa5 commit feec066
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, 0, d1, Some("rev1")).is_some());
assert!(parse_expected(None, 0, d1, Some("rev2")).is_some());
assert!(parse_expected(None, 0, d2, Some("rev1")).is_some());
assert!(parse_expected(None, 0, d2, Some("rev2-foo")).is_some());
}

0 comments on commit feec066

Please sign in to comment.