Skip to content

Commit d9566ee

Browse files
committed
Require a colon in //@ normalize-*: headers
1 parent c208361 commit d9566ee

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/tools/compiletest/src/header.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1315,13 +1315,11 @@ fn expand_variables(mut value: String, config: &Config) -> String {
13151315
/// normalize-*: "REGEX" -> "REPLACEMENT"
13161316
/// ```
13171317
fn parse_normalize_rule(header: &str) -> Option<(String, String)> {
1318-
// FIXME(#126370): A colon after the header name should be mandatory, but
1319-
// currently is not, and there are many tests that lack the colon.
13201318
// FIXME: Support escaped double-quotes in strings.
13211319
let captures = static_regex!(
13221320
r#"(?x) # (verbose mode regex)
13231321
^
1324-
[^:\s]+:?\s* # (header name followed by optional colon)
1322+
[^:\s]+:\s* # (header name followed by colon)
13251323
"(?<regex>[^"]*)" # "REGEX"
13261324
\s+->\s+ # ->
13271325
"(?<replacement>[^"]*)" # "REPLACEMENT"

src/tools/compiletest/src/header/tests.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,11 @@ fn make_test_description<R: Read>(
3333

3434
#[test]
3535
fn test_parse_normalize_rule() {
36-
let good_data = &[
37-
(
38-
r#"normalize-stderr-32bit: "something (32 bits)" -> "something ($WORD bits)""#,
39-
"something (32 bits)",
40-
"something ($WORD bits)",
41-
),
42-
// FIXME(#126370): A colon after the header name should be mandatory,
43-
// but currently is not, and there are many tests that lack the colon.
44-
(
45-
r#"normalize-stderr-32bit "something (32 bits)" -> "something ($WORD bits)""#,
46-
"something (32 bits)",
47-
"something ($WORD bits)",
48-
),
49-
];
36+
let good_data = &[(
37+
r#"normalize-stderr-32bit: "something (32 bits)" -> "something ($WORD bits)""#,
38+
"something (32 bits)",
39+
"something ($WORD bits)",
40+
)];
5041

5142
for &(input, expected_regex, expected_replacement) in good_data {
5243
let parsed = parse_normalize_rule(input);
@@ -56,6 +47,7 @@ fn test_parse_normalize_rule() {
5647
}
5748

5849
let bad_data = &[
50+
r#"normalize-stderr-32bit "something (32 bits)" -> "something ($WORD bits)""#,
5951
r#"normalize-stderr-16bit: something (16 bits) -> something ($WORD bits)"#,
6052
r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)"#,
6153
r#"normalize-stderr-32bit: "something (32 bits) -> something ($WORD bits)"#,

0 commit comments

Comments
 (0)