@@ -934,6 +934,20 @@ pub fn make_test_description<R: Read>(
934
934
}
935
935
} ;
936
936
}
937
+ macro_rules! decision {
938
+ ( $e: expr) => {
939
+ match $e {
940
+ IgnoreDecision :: Ignore { reason } => {
941
+ ignore = true ;
942
+ // The ignore reason must be a &'static str, so we have to leak memory to
943
+ // create it. This is fine, as the header is parsed only at the start of
944
+ // compiletest so it won't grow indefinitely.
945
+ ignore_message = Some ( Box :: leak( Box :: <str >:: from( reason) ) ) ;
946
+ }
947
+ IgnoreDecision :: Continue => { }
948
+ }
949
+ } ;
950
+ }
937
951
938
952
{
939
953
let parsed = parse_cfg_name_directive ( config, ln, "ignore" ) ;
@@ -975,7 +989,11 @@ pub fn make_test_description<R: Read>(
975
989
} ;
976
990
}
977
991
978
- reason ! ( ignore_llvm( config, ln) ) ;
992
+ decision ! ( ignore_llvm( config, ln) ) ;
993
+ decision ! ( ignore_cdb( config, ln) ) ;
994
+ decision ! ( ignore_gdb( config, ln) ) ;
995
+ decision ! ( ignore_lldb( config, ln) ) ;
996
+
979
997
reason ! (
980
998
config. run_clang_based_tests_with. is_none( ) && config. parse_needs_matching_clang( ln)
981
999
) ;
@@ -1005,12 +1023,15 @@ pub fn make_test_description<R: Read>(
1005
1023
config. target == "wasm32-unknown-unknown"
1006
1024
&& config. parse_name_directive( ln, directives:: CHECK_RUN_RESULTS )
1007
1025
) ;
1008
- reason ! ( config. debugger == Some ( Debugger :: Cdb ) && ignore_cdb( config, ln) ) ;
1009
- reason ! ( config. debugger == Some ( Debugger :: Gdb ) && ignore_gdb( config, ln) ) ;
1010
- reason ! ( config. debugger == Some ( Debugger :: Lldb ) && ignore_lldb( config, ln) ) ;
1011
1026
reason ! ( !has_rust_lld && config. parse_name_directive( ln, "needs-rust-lld" ) ) ;
1012
1027
reason ! ( config. parse_name_directive( ln, "needs-i686-dlltool" ) && !has_i686_dlltool( ) ) ;
1013
1028
reason ! ( config. parse_name_directive( ln, "needs-x86_64-dlltool" ) && !has_x86_64_dlltool( ) ) ;
1029
+ reason ! (
1030
+ config. parse_name_directive( ln, "rust-lldb" )
1031
+ && config. debugger == Some ( Debugger :: Lldb )
1032
+ && !config. lldb_native_rust
1033
+ ) ;
1034
+
1014
1035
should_fail |= config. parse_name_directive ( ln, "should-fail" ) ;
1015
1036
} ) ;
1016
1037
@@ -1044,22 +1065,34 @@ pub fn make_test_description<R: Read>(
1044
1065
}
1045
1066
}
1046
1067
1047
- fn ignore_cdb ( config : & Config , line : & str ) -> bool {
1068
+ fn ignore_cdb ( config : & Config , line : & str ) -> IgnoreDecision {
1069
+ if config. debugger != Some ( Debugger :: Cdb ) {
1070
+ return IgnoreDecision :: Continue ;
1071
+ }
1072
+
1048
1073
if let Some ( actual_version) = config. cdb_version {
1049
- if let Some ( min_version ) = line. strip_prefix ( "min-cdb-version:" ) . map ( str:: trim) {
1050
- let min_version = extract_cdb_version ( min_version ) . unwrap_or_else ( || {
1051
- panic ! ( "couldn't parse version range: {:?}" , min_version ) ;
1074
+ if let Some ( rest ) = line. strip_prefix ( "min-cdb-version:" ) . map ( str:: trim) {
1075
+ let min_version = extract_cdb_version ( rest ) . unwrap_or_else ( || {
1076
+ panic ! ( "couldn't parse version range: {:?}" , rest ) ;
1052
1077
} ) ;
1053
1078
1054
1079
// Ignore if actual version is smaller than the minimum
1055
1080
// required version
1056
- return actual_version < min_version;
1081
+ if actual_version < min_version {
1082
+ return IgnoreDecision :: Ignore {
1083
+ reason : format ! ( "ignored when the CDB version is lower than {rest}" ) ,
1084
+ } ;
1085
+ }
1057
1086
}
1058
1087
}
1059
- false
1088
+ IgnoreDecision :: Continue
1060
1089
}
1061
1090
1062
- fn ignore_gdb ( config : & Config , line : & str ) -> bool {
1091
+ fn ignore_gdb ( config : & Config , line : & str ) -> IgnoreDecision {
1092
+ if config. debugger != Some ( Debugger :: Gdb ) {
1093
+ return IgnoreDecision :: Continue ;
1094
+ }
1095
+
1063
1096
if let Some ( actual_version) = config. gdb_version {
1064
1097
if let Some ( rest) = line. strip_prefix ( "min-gdb-version:" ) . map ( str:: trim) {
1065
1098
let ( start_ver, end_ver) = extract_version_range ( rest, extract_gdb_version)
@@ -1072,7 +1105,11 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
1072
1105
}
1073
1106
// Ignore if actual version is smaller than the minimum
1074
1107
// required version
1075
- return actual_version < start_ver;
1108
+ if actual_version < start_ver {
1109
+ return IgnoreDecision :: Ignore {
1110
+ reason : format ! ( "ignored when the GDB version is lower than {rest}" ) ,
1111
+ } ;
1112
+ }
1076
1113
} else if let Some ( rest) = line. strip_prefix ( "ignore-gdb-version:" ) . map ( str:: trim) {
1077
1114
let ( min_version, max_version) = extract_version_range ( rest, extract_gdb_version)
1078
1115
. unwrap_or_else ( || {
@@ -1083,32 +1120,47 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
1083
1120
panic ! ( "Malformed GDB version range: max < min" )
1084
1121
}
1085
1122
1086
- return actual_version >= min_version && actual_version <= max_version;
1123
+ if actual_version >= min_version && actual_version <= max_version {
1124
+ if min_version == max_version {
1125
+ return IgnoreDecision :: Ignore {
1126
+ reason : format ! ( "ignored when the GDB version is {rest}" ) ,
1127
+ } ;
1128
+ } else {
1129
+ return IgnoreDecision :: Ignore {
1130
+ reason : format ! ( "ignored when the GDB version is between {rest}" ) ,
1131
+ } ;
1132
+ }
1133
+ }
1087
1134
}
1088
1135
}
1089
- false
1136
+ IgnoreDecision :: Continue
1090
1137
}
1091
1138
1092
- fn ignore_lldb ( config : & Config , line : & str ) -> bool {
1139
+ fn ignore_lldb ( config : & Config , line : & str ) -> IgnoreDecision {
1140
+ if config. debugger != Some ( Debugger :: Lldb ) {
1141
+ return IgnoreDecision :: Continue ;
1142
+ }
1143
+
1093
1144
if let Some ( actual_version) = config. lldb_version {
1094
- if let Some ( min_version ) = line. strip_prefix ( "min-lldb-version:" ) . map ( str:: trim) {
1095
- let min_version = min_version . parse ( ) . unwrap_or_else ( |e| {
1096
- panic ! ( "Unexpected format of LLDB version string: {}\n {:?}" , min_version , e) ;
1145
+ if let Some ( rest ) = line. strip_prefix ( "min-lldb-version:" ) . map ( str:: trim) {
1146
+ let min_version = rest . parse ( ) . unwrap_or_else ( |e| {
1147
+ panic ! ( "Unexpected format of LLDB version string: {}\n {:?}" , rest , e) ;
1097
1148
} ) ;
1098
1149
// Ignore if actual version is smaller the minimum required
1099
1150
// version
1100
- actual_version < min_version
1101
- } else {
1102
- line. starts_with ( "rust-lldb" ) && !config. lldb_native_rust
1151
+ if actual_version < min_version {
1152
+ return IgnoreDecision :: Ignore {
1153
+ reason : format ! ( "ignored when the LLDB version is {rest}" ) ,
1154
+ } ;
1155
+ }
1103
1156
}
1104
- } else {
1105
- false
1106
1157
}
1158
+ IgnoreDecision :: Continue
1107
1159
}
1108
1160
1109
- fn ignore_llvm ( config : & Config , line : & str ) -> bool {
1161
+ fn ignore_llvm ( config : & Config , line : & str ) -> IgnoreDecision {
1110
1162
if config. system_llvm && line. starts_with ( "no-system-llvm" ) {
1111
- return true ;
1163
+ return IgnoreDecision :: Ignore { reason : "ignored when the system LLVM is used" . into ( ) } ;
1112
1164
}
1113
1165
if let Some ( needed_components) =
1114
1166
config. parse_name_value_directive ( line, "needs-llvm-components" )
@@ -1121,20 +1173,30 @@ fn ignore_llvm(config: &Config, line: &str) -> bool {
1121
1173
if env:: var_os ( "COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS" ) . is_some ( ) {
1122
1174
panic ! ( "missing LLVM component: {}" , missing_component) ;
1123
1175
}
1124
- return true ;
1176
+ return IgnoreDecision :: Ignore {
1177
+ reason : format ! ( "ignored when the {missing_component} LLVM component is missing" ) ,
1178
+ } ;
1125
1179
}
1126
1180
}
1127
1181
if let Some ( actual_version) = config. llvm_version {
1128
1182
if let Some ( rest) = line. strip_prefix ( "min-llvm-version:" ) . map ( str:: trim) {
1129
1183
let min_version = extract_llvm_version ( rest) . unwrap ( ) ;
1130
1184
// Ignore if actual version is smaller the minimum required
1131
1185
// version
1132
- actual_version < min_version
1186
+ if actual_version < min_version {
1187
+ return IgnoreDecision :: Ignore {
1188
+ reason : format ! ( "ignored when the LLVM version is older than {rest}" ) ,
1189
+ } ;
1190
+ }
1133
1191
} else if let Some ( rest) = line. strip_prefix ( "min-system-llvm-version:" ) . map ( str:: trim) {
1134
1192
let min_version = extract_llvm_version ( rest) . unwrap ( ) ;
1135
1193
// Ignore if using system LLVM and actual version
1136
1194
// is smaller the minimum required version
1137
- config. system_llvm && actual_version < min_version
1195
+ if config. system_llvm && actual_version < min_version {
1196
+ return IgnoreDecision :: Ignore {
1197
+ reason : format ! ( "ignored when the system LLVM version is older than {rest}" ) ,
1198
+ } ;
1199
+ }
1138
1200
} else if let Some ( rest) = line. strip_prefix ( "ignore-llvm-version:" ) . map ( str:: trim) {
1139
1201
// Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
1140
1202
let ( v_min, v_max) =
@@ -1145,11 +1207,23 @@ fn ignore_llvm(config: &Config, line: &str) -> bool {
1145
1207
panic ! ( "Malformed LLVM version range: max < min" )
1146
1208
}
1147
1209
// Ignore if version lies inside of range.
1148
- actual_version >= v_min && actual_version <= v_max
1149
- } else {
1150
- false
1210
+ if actual_version >= v_min && actual_version <= v_max {
1211
+ if v_min == v_max {
1212
+ return IgnoreDecision :: Ignore {
1213
+ reason : format ! ( "ignored when the LLVM version is {rest}" ) ,
1214
+ } ;
1215
+ } else {
1216
+ return IgnoreDecision :: Ignore {
1217
+ reason : format ! ( "ignored when the LLVM version is between {rest}" ) ,
1218
+ } ;
1219
+ }
1220
+ }
1151
1221
}
1152
- } else {
1153
- false
1154
1222
}
1223
+ IgnoreDecision :: Continue
1224
+ }
1225
+
1226
+ enum IgnoreDecision {
1227
+ Ignore { reason : String } ,
1228
+ Continue ,
1155
1229
}
0 commit comments