Skip to content

Commit feec066

Browse files
committed
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 also match strings that contain a `-`.h
1 parent d1a0fa5 commit feec066

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/tools/compiletest/src/errors.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ fn parse_expected(
118118
// //[rev1]~
119119
// //[rev1,rev2]~^^
120120
static RE: Lazy<Regex> =
121-
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());
121+
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w\-,]+)])?~(?P<adjust>\||\^*)").unwrap());
122122

123123
let captures = RE.captures(line)?;
124124

@@ -178,3 +178,6 @@ fn parse_expected(
178178
);
179179
Some((which, Error { line_num, kind, msg }))
180180
}
181+
182+
#[cfg(test)]
183+
mod tests;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use super::*;
2+
3+
#[test]
4+
fn test_parse_expected_matching() {
5+
// Ensure that we correctly extract expected revisions
6+
let d1 = "//[rev1,rev2]~^ ERROR foo";
7+
let d2 = "//[rev1,rev2-foo]~^ ERROR foo";
8+
assert!(parse_expected(None, 0, d1, Some("rev1")).is_some());
9+
assert!(parse_expected(None, 0, d1, Some("rev2")).is_some());
10+
assert!(parse_expected(None, 0, d2, Some("rev1")).is_some());
11+
assert!(parse_expected(None, 0, d2, Some("rev2-foo")).is_some());
12+
}

0 commit comments

Comments
 (0)