mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 10:13:54 +00:00
Require a colon in //@ normalize-*:
headers
This commit is contained in:
parent
9aaa0c5867
commit
b6773591ee
@ -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"
|
||||
|
@ -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)"#,
|
||||
|
Loading…
Reference in New Issue
Block a user