@@ -12,7 +12,6 @@ use tracing::*;
1212use crate :: common:: { Config , Debugger , FailMode , Mode , PassMode } ;
1313use crate :: debuggers:: { extract_cdb_version, extract_gdb_version} ;
1414use crate :: header:: auxiliary:: { AuxProps , parse_and_update_aux} ;
15- use crate :: header:: cfg:: { MatchOutcome , parse_cfg_name_directive} ;
1615use crate :: header:: needs:: CachedNeedsConditions ;
1716use crate :: util:: static_regex;
1817
@@ -472,11 +471,24 @@ impl TestProps {
472471
473472 config. set_name_directive ( ln, IGNORE_PASS , & mut self . ignore_pass ) ;
474473
475- if let Some ( rule) = config. parse_custom_normalization ( ln, "normalize-stdout" ) {
476- self . normalize_stdout . push ( rule) ;
477- }
478- if let Some ( rule) = config. parse_custom_normalization ( ln, "normalize-stderr" ) {
479- self . normalize_stderr . push ( rule) ;
474+ if let Some ( NormalizeRule { kind, regex, replacement } ) =
475+ config. parse_custom_normalization ( ln)
476+ {
477+ let rule_tuple = ( regex, replacement) ;
478+ match kind {
479+ NormalizeKind :: Stdout => self . normalize_stdout . push ( rule_tuple) ,
480+ NormalizeKind :: Stderr => self . normalize_stderr . push ( rule_tuple) ,
481+ NormalizeKind :: Stderr32bit => {
482+ if config. target_cfg ( ) . pointer_width == 32 {
483+ self . normalize_stderr . push ( rule_tuple) ;
484+ }
485+ }
486+ NormalizeKind :: Stderr64bit => {
487+ if config. target_cfg ( ) . pointer_width == 64 {
488+ self . normalize_stderr . push ( rule_tuple) ;
489+ }
490+ }
491+ }
480492 }
481493
482494 if let Some ( code) = config
@@ -966,20 +978,28 @@ impl Config {
966978 }
967979 }
968980
969- fn parse_custom_normalization ( & self , line : & str , prefix : & str ) -> Option < ( String , String ) > {
970- let parsed = parse_cfg_name_directive ( self , line, prefix) ;
971- if parsed. outcome != MatchOutcome :: Match {
972- return None ;
973- }
974- let name = parsed. name . expect ( "successful match always has a name" ) ;
981+ fn parse_custom_normalization ( & self , line : & str ) -> Option < NormalizeRule > {
982+ // FIXME(Zalathar): Integrate name/value splitting into `DirectiveLine`
983+ // instead of doing it here.
984+ let ( directive_name, _value) = line. split_once ( ':' ) ?;
985+
986+ let kind = match directive_name {
987+ "normalize-stdout-test" => NormalizeKind :: Stdout ,
988+ "normalize-stderr-test" => NormalizeKind :: Stderr ,
989+ "normalize-stderr-32bit" => NormalizeKind :: Stderr32bit ,
990+ "normalize-stderr-64bit" => NormalizeKind :: Stderr64bit ,
991+ _ => return None ,
992+ } ;
975993
994+ // FIXME(Zalathar): The normalize rule parser should only care about
995+ // the value part, not the "line" (which isn't even the whole line).
976996 let Some ( ( regex, replacement) ) = parse_normalize_rule ( line) else {
977997 panic ! (
978998 "couldn't parse custom normalization rule: `{line}`\n \
979- help: expected syntax is: `{prefix}-{name }: \" REGEX\" -> \" REPLACEMENT\" `"
999+ help: expected syntax is: `{directive_name }: \" REGEX\" -> \" REPLACEMENT\" `"
9801000 ) ;
9811001 } ;
982- Some ( ( regex, replacement) )
1002+ Some ( NormalizeRule { kind , regex, replacement } )
9831003 }
9841004
9851005 fn parse_name_directive ( & self , line : & str , directive : & str ) -> bool {
@@ -1105,6 +1125,19 @@ fn expand_variables(mut value: String, config: &Config) -> String {
11051125 value
11061126}
11071127
1128+ struct NormalizeRule {
1129+ kind : NormalizeKind ,
1130+ regex : String ,
1131+ replacement : String ,
1132+ }
1133+
1134+ enum NormalizeKind {
1135+ Stdout ,
1136+ Stderr ,
1137+ Stderr32bit ,
1138+ Stderr64bit ,
1139+ }
1140+
11081141/// Parses the regex and replacement values of a `//@ normalize-*` header,
11091142/// in the format:
11101143/// ```text
0 commit comments