@@ -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,24 @@ 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
+ let directive_name = line. split_once ( ':' ) ?. 0 ;
983
+
984
+ let kind = match directive_name {
985
+ "normalize-stdout-test" => NormalizeKind :: Stdout ,
986
+ "normalize-stderr-test" => NormalizeKind :: Stderr ,
987
+ "normalize-stderr-32bit" => NormalizeKind :: Stderr32bit ,
988
+ "normalize-stderr-64bit" => NormalizeKind :: Stderr64bit ,
989
+ _ => return None ,
990
+ } ;
975
991
976
992
let Some ( ( regex, replacement) ) = parse_normalize_rule ( line) else {
977
993
panic ! (
978
994
"couldn't parse custom normalization rule: `{line}`\n \
979
- help: expected syntax is: `{prefix}-{name }: \" REGEX\" -> \" REPLACEMENT\" `"
995
+ help: expected syntax is: `{directive_name }: \" REGEX\" -> \" REPLACEMENT\" `"
980
996
) ;
981
997
} ;
982
- Some ( ( regex, replacement) )
998
+ Some ( NormalizeRule { kind , regex, replacement } )
983
999
}
984
1000
985
1001
fn parse_name_directive ( & self , line : & str , directive : & str ) -> bool {
@@ -1105,6 +1121,19 @@ fn expand_variables(mut value: String, config: &Config) -> String {
1105
1121
value
1106
1122
}
1107
1123
1124
+ struct NormalizeRule {
1125
+ kind : NormalizeKind ,
1126
+ regex : String ,
1127
+ replacement : String ,
1128
+ }
1129
+
1130
+ enum NormalizeKind {
1131
+ Stdout ,
1132
+ Stderr ,
1133
+ Stderr32bit ,
1134
+ Stderr64bit ,
1135
+ }
1136
+
1108
1137
/// Parses the regex and replacement values of a `//@ normalize-*` header,
1109
1138
/// in the format:
1110
1139
/// ```text
0 commit comments