@@ -934,6 +934,20 @@ pub fn make_test_description<R: Read>(
934934 }
935935 } ;
936936 }
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+ }
937951
938952 {
939953 let parsed = parse_cfg_name_directive ( config, ln, "ignore" ) ;
@@ -975,7 +989,11 @@ pub fn make_test_description<R: Read>(
975989 } ;
976990 }
977991
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+
979997 reason ! (
980998 config. run_clang_based_tests_with. is_none( ) && config. parse_needs_matching_clang( ln)
981999 ) ;
@@ -1005,12 +1023,15 @@ pub fn make_test_description<R: Read>(
10051023 config. target == "wasm32-unknown-unknown"
10061024 && config. parse_name_directive( ln, directives:: CHECK_RUN_RESULTS )
10071025 ) ;
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) ) ;
10111026 reason ! ( !has_rust_lld && config. parse_name_directive( ln, "needs-rust-lld" ) ) ;
10121027 reason ! ( config. parse_name_directive( ln, "needs-i686-dlltool" ) && !has_i686_dlltool( ) ) ;
10131028 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+
10141035 should_fail |= config. parse_name_directive ( ln, "should-fail" ) ;
10151036 } ) ;
10161037
@@ -1044,22 +1065,34 @@ pub fn make_test_description<R: Read>(
10441065 }
10451066}
10461067
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+
10481073 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 ) ;
10521077 } ) ;
10531078
10541079 // Ignore if actual version is smaller than the minimum
10551080 // 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+ }
10571086 }
10581087 }
1059- false
1088+ IgnoreDecision :: Continue
10601089}
10611090
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+
10631096 if let Some ( actual_version) = config. gdb_version {
10641097 if let Some ( rest) = line. strip_prefix ( "min-gdb-version:" ) . map ( str:: trim) {
10651098 let ( start_ver, end_ver) = extract_version_range ( rest, extract_gdb_version)
@@ -1072,7 +1105,11 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
10721105 }
10731106 // Ignore if actual version is smaller than the minimum
10741107 // 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+ }
10761113 } else if let Some ( rest) = line. strip_prefix ( "ignore-gdb-version:" ) . map ( str:: trim) {
10771114 let ( min_version, max_version) = extract_version_range ( rest, extract_gdb_version)
10781115 . unwrap_or_else ( || {
@@ -1083,32 +1120,47 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
10831120 panic ! ( "Malformed GDB version range: max < min" )
10841121 }
10851122
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+ }
10871134 }
10881135 }
1089- false
1136+ IgnoreDecision :: Continue
10901137}
10911138
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+
10931144 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) ;
10971148 } ) ;
10981149 // Ignore if actual version is smaller the minimum required
10991150 // 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+ }
11031156 }
1104- } else {
1105- false
11061157 }
1158+ IgnoreDecision :: Continue
11071159}
11081160
1109- fn ignore_llvm ( config : & Config , line : & str ) -> bool {
1161+ fn ignore_llvm ( config : & Config , line : & str ) -> IgnoreDecision {
11101162 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 ( ) } ;
11121164 }
11131165 if let Some ( needed_components) =
11141166 config. parse_name_value_directive ( line, "needs-llvm-components" )
@@ -1121,20 +1173,30 @@ fn ignore_llvm(config: &Config, line: &str) -> bool {
11211173 if env:: var_os ( "COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS" ) . is_some ( ) {
11221174 panic ! ( "missing LLVM component: {}" , missing_component) ;
11231175 }
1124- return true ;
1176+ return IgnoreDecision :: Ignore {
1177+ reason : format ! ( "ignored when the {missing_component} LLVM component is missing" ) ,
1178+ } ;
11251179 }
11261180 }
11271181 if let Some ( actual_version) = config. llvm_version {
11281182 if let Some ( rest) = line. strip_prefix ( "min-llvm-version:" ) . map ( str:: trim) {
11291183 let min_version = extract_llvm_version ( rest) . unwrap ( ) ;
11301184 // Ignore if actual version is smaller the minimum required
11311185 // 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+ }
11331191 } else if let Some ( rest) = line. strip_prefix ( "min-system-llvm-version:" ) . map ( str:: trim) {
11341192 let min_version = extract_llvm_version ( rest) . unwrap ( ) ;
11351193 // Ignore if using system LLVM and actual version
11361194 // 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+ }
11381200 } else if let Some ( rest) = line. strip_prefix ( "ignore-llvm-version:" ) . map ( str:: trim) {
11391201 // Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
11401202 let ( v_min, v_max) =
@@ -1145,11 +1207,23 @@ fn ignore_llvm(config: &Config, line: &str) -> bool {
11451207 panic ! ( "Malformed LLVM version range: max < min" )
11461208 }
11471209 // 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+ }
11511221 }
1152- } else {
1153- false
11541222 }
1223+ IgnoreDecision :: Continue
1224+ }
1225+
1226+ enum IgnoreDecision {
1227+ Ignore { reason : String } ,
1228+ Continue ,
11551229}
0 commit comments