@@ -12,7 +12,6 @@ use tracing::*;
12
12
use crate :: common:: { Config , Debugger , FailMode , Mode , PassMode } ;
13
13
use crate :: debuggers:: { extract_cdb_version, extract_gdb_version} ;
14
14
use crate :: header:: auxiliary:: { AuxProps , parse_and_update_aux} ;
15
- use crate :: header:: cfg:: { MatchOutcome , parse_cfg_name_directive} ;
16
15
use crate :: header:: needs:: CachedNeedsConditions ;
17
16
use crate :: util:: static_regex;
18
17
@@ -472,11 +471,24 @@ impl TestProps {
472
471
473
472
config. set_name_directive ( ln, IGNORE_PASS , & mut self . ignore_pass ) ;
474
473
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
+ }
480
492
}
481
493
482
494
if let Some ( code) = config
@@ -966,20 +978,28 @@ impl Config {
966
978
}
967
979
}
968
980
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
+ } ;
975
993
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).
976
996
let Some ( ( regex, replacement) ) = parse_normalize_rule ( line) else {
977
997
panic ! (
978
998
"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\" `"
980
1000
) ;
981
1001
} ;
982
- Some ( ( regex, replacement) )
1002
+ Some ( NormalizeRule { kind , regex, replacement } )
983
1003
}
984
1004
985
1005
fn parse_name_directive ( & self , line : & str , directive : & str ) -> bool {
@@ -1105,6 +1125,19 @@ fn expand_variables(mut value: String, config: &Config) -> String {
1105
1125
value
1106
1126
}
1107
1127
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
+
1108
1141
/// Parses the regex and replacement values of a `//@ normalize-*` header,
1109
1142
/// in the format:
1110
1143
/// ```text
0 commit comments