Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fdf7ea6

Browse files
committedJul 11, 2024
Auto merge of #126777 - Zalathar:normalize-colon, r=lcnr
Require a colon in `//@ normalize-*:` test headers The previous parser for `//@ normalize-*` headers (before #126370) was so lax that it did not require `:` after the header name. As a result, the test suite contained a mix of with-colon and without-colon normalize headers, both numbering in the hundreds. This PR updates the without-colon headers to add a colon (matching the style used by other headers), and then updates the parser to make the colon mandatory. (Because the normalization parser only runs *after* the header system identifies a normalize header, this will detect and issue an error for relevant headers that lack the colon.) Addresses one of the points of #126372.
2 parents 9b00430 + b677359 commit fdf7ea6

File tree

134 files changed

+235
-245
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+235
-245
lines changed
 

‎src/tools/compiletest/src/header.rs

Lines changed: 1 addition & 3 deletions
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

Lines changed: 6 additions & 14 deletions
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)
Please sign in to comment.