about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-11 09:13:15 +0000
committerbors <bors@rust-lang.org>2024-07-11 09:13:15 +0000
commitfdf7ea6b5b1cac83c0f29e681202cf18bf25b01c (patch)
tree24e9f6e8d4767400cb3e088d5ebacbd4bf746b1f /src/tools
parent9b0043095a2ddceb2ddad7704c084293d0c8cd09 (diff)
parentb6773591ee82df4d57157252f5122e280be3786d (diff)
downloadrust-fdf7ea6b5b1cac83c0f29e681202cf18bf25b01c.tar.gz
rust-fdf7ea6b5b1cac83c0f29e681202cf18bf25b01c.zip
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.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/compiletest/src/header.rs4
-rw-r--r--src/tools/compiletest/src/header/tests.rs20
2 files changed, 7 insertions, 17 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 63d1efd42fa..7479be90797 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -1121,13 +1121,11 @@ fn expand_variables(mut value: String, config: &Config) -> String {
 /// normalize-*: "REGEX" -> "REPLACEMENT"
 /// ```
 fn parse_normalize_rule(header: &str) -> Option<(String, String)> {
-    // FIXME(#126370): A colon after the header name should be mandatory, but
-    // currently is not, and there are many tests that lack the colon.
     // FIXME: Support escaped double-quotes in strings.
     let captures = static_regex!(
         r#"(?x) # (verbose mode regex)
         ^
-        [^:\s]+:?\s*            # (header name followed by optional colon)
+        [^:\s]+:\s*             # (header name followed by colon)
         "(?<regex>[^"]*)"       # "REGEX"
         \s+->\s+                # ->
         "(?<replacement>[^"]*)" # "REPLACEMENT"
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index 61a85b84ad6..c790eb18d67 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -33,20 +33,11 @@ fn make_test_description<R: Read>(
 
 #[test]
 fn test_parse_normalize_rule() {
-    let good_data = &[
-        (
-            r#"normalize-stderr-32bit: "something (32 bits)" -> "something ($WORD bits)""#,
-            "something (32 bits)",
-            "something ($WORD bits)",
-        ),
-        // FIXME(#126370): A colon after the header name should be mandatory,
-        // but currently is not, and there are many tests that lack the colon.
-        (
-            r#"normalize-stderr-32bit "something (32 bits)" -> "something ($WORD bits)""#,
-            "something (32 bits)",
-            "something ($WORD bits)",
-        ),
-    ];
+    let good_data = &[(
+        r#"normalize-stderr-32bit: "something (32 bits)" -> "something ($WORD bits)""#,
+        "something (32 bits)",
+        "something ($WORD bits)",
+    )];
 
     for &(input, expected_regex, expected_replacement) in good_data {
         let parsed = parse_normalize_rule(input);
@@ -56,6 +47,7 @@ fn test_parse_normalize_rule() {
     }
 
     let bad_data = &[
+        r#"normalize-stderr-32bit "something (32 bits)" -> "something ($WORD bits)""#,
         r#"normalize-stderr-16bit: something (16 bits) -> something ($WORD bits)"#,
         r#"normalize-stderr-32bit: something (32 bits) -> something ($WORD bits)"#,
         r#"normalize-stderr-32bit: "something (32 bits) -> something ($WORD bits)"#,