Skip to content

Commit 5d099f8

Browse files
committed
Require a colon in //@ normalize-*: headers
1 parent fb13a98 commit 5d099f8

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
@@ -1121,13 +1121,11 @@ fn expand_variables(mut value: String, config: &Config) -> String {
11211121
/// normalize-*: "REGEX" -> "REPLACEMENT"
11221122
/// ```
11231123
fn parse_normalize_rule(header: &str) -> Option<(String, String)> {
1124-
// FIXME(#126370): A colon after the header name should be mandatory, but
1125-
// currently is not, and there are many tests that lack the colon.
11261124
// FIXME: Support escaped double-quotes in strings.
11271125
let captures = static_regex!(
11281126
r#"(?x) # (verbose mode regex)
11291127
^
1130-
[^:\s]+:?\s* # (header name followed by optional colon)
1128+
[^:\s]+:\s* # (header name followed by colon)
11311129
"(?<regex>[^"]*)" # "REGEX"
11321130
\s+->\s+ # ->
11331131
"(?<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)