@@ -6,69 +6,26 @@ use std::path::{Path, PathBuf};
66
77use log:: * ;
88
9- use crate :: common:: { self , CompareMode , Config , FailMode , Mode , PassMode } ;
9+ use crate :: common:: { CompareMode , Config , Debugger , FailMode , Mode , PassMode } ;
1010use crate :: extract_gdb_version;
1111use crate :: util;
1212
1313#[ cfg( test) ]
1414mod tests;
1515
16- /// Whether to ignore the test.
17- #[ derive( Clone , Copy , PartialEq , Debug ) ]
18- pub enum Ignore {
19- /// Runs it.
20- Run ,
21- /// Ignore it totally.
22- Ignore ,
23- /// Ignore only the gdb test, but run the lldb test.
24- IgnoreGdb ,
25- /// Ignore only the lldb test, but run the gdb test.
26- IgnoreLldb ,
27- }
28-
29- impl Ignore {
30- pub fn can_run_gdb ( & self ) -> bool {
31- * self == Ignore :: Run || * self == Ignore :: IgnoreLldb
32- }
33-
34- pub fn can_run_lldb ( & self ) -> bool {
35- * self == Ignore :: Run || * self == Ignore :: IgnoreGdb
36- }
37-
38- pub fn no_gdb ( & self ) -> Ignore {
39- match * self {
40- Ignore :: Run => Ignore :: IgnoreGdb ,
41- Ignore :: IgnoreGdb => Ignore :: IgnoreGdb ,
42- _ => Ignore :: Ignore ,
43- }
44- }
45-
46- pub fn no_lldb ( & self ) -> Ignore {
47- match * self {
48- Ignore :: Run => Ignore :: IgnoreLldb ,
49- Ignore :: IgnoreLldb => Ignore :: IgnoreLldb ,
50- _ => Ignore :: Ignore ,
51- }
52- }
53- }
54-
5516/// The result of parse_cfg_name_directive.
5617#[ derive( Clone , Copy , PartialEq , Debug ) ]
5718enum ParsedNameDirective {
5819 /// No match.
5920 NoMatch ,
6021 /// Match.
6122 Match ,
62- /// Mode was DebugInfoGdbLldb and this matched gdb.
63- MatchGdb ,
64- /// Mode was DebugInfoGdbLldb and this matched lldb.
65- MatchLldb ,
6623}
6724
6825/// Properties which must be known very early, before actually running
6926/// the test.
7027pub struct EarlyProps {
71- pub ignore : Ignore ,
28+ pub ignore : bool ,
7229 pub should_fail : bool ,
7330 pub aux : Vec < String > ,
7431 pub aux_crate : Vec < ( String , String ) > ,
@@ -78,84 +35,61 @@ pub struct EarlyProps {
7835impl EarlyProps {
7936 pub fn from_file ( config : & Config , testfile : & Path ) -> Self {
8037 let mut props = EarlyProps {
81- ignore : Ignore :: Run ,
38+ ignore : false ,
8239 should_fail : false ,
8340 aux : Vec :: new ( ) ,
8441 aux_crate : Vec :: new ( ) ,
8542 revisions : vec ! [ ] ,
8643 } ;
8744
88- if config. mode == common:: DebugInfoGdbLldb {
89- if config. lldb_python_dir . is_none ( ) {
90- props. ignore = props. ignore . no_lldb ( ) ;
91- }
92- if config. gdb_version . is_none ( ) {
93- props. ignore = props. ignore . no_gdb ( ) ;
94- }
95- } else if config. mode == common:: DebugInfoCdb {
96- if config. cdb . is_none ( ) {
97- props. ignore = Ignore :: Ignore ;
98- }
99- }
100-
10145 let rustc_has_profiler_support = env:: var_os ( "RUSTC_PROFILER_SUPPORT" ) . is_some ( ) ;
10246 let rustc_has_sanitizer_support = env:: var_os ( "RUSTC_SANITIZER_SUPPORT" ) . is_some ( ) ;
10347
10448 iter_header ( testfile, None , & mut |ln| {
10549 // we should check if any only-<platform> exists and if it exists
10650 // and does not matches the current platform, skip the test
107- if props. ignore != Ignore :: Ignore {
51+ if ! props. ignore {
10852 props. ignore = match config. parse_cfg_name_directive ( ln, "ignore" ) {
109- ParsedNameDirective :: Match => Ignore :: Ignore ,
53+ ParsedNameDirective :: Match => true ,
11054 ParsedNameDirective :: NoMatch => props. ignore ,
111- ParsedNameDirective :: MatchGdb => props. ignore . no_gdb ( ) ,
112- ParsedNameDirective :: MatchLldb => props. ignore . no_lldb ( ) ,
11355 } ;
11456
11557 if config. has_cfg_prefix ( ln, "only" ) {
11658 props. ignore = match config. parse_cfg_name_directive ( ln, "only" ) {
11759 ParsedNameDirective :: Match => props. ignore ,
118- ParsedNameDirective :: NoMatch => Ignore :: Ignore ,
119- ParsedNameDirective :: MatchLldb => props. ignore . no_gdb ( ) ,
120- ParsedNameDirective :: MatchGdb => props. ignore . no_lldb ( ) ,
60+ ParsedNameDirective :: NoMatch => true ,
12161 } ;
12262 }
12363
12464 if ignore_llvm ( config, ln) {
125- props. ignore = Ignore :: Ignore ;
65+ props. ignore = true ;
12666 }
12767
12868 if config. run_clang_based_tests_with . is_none ( )
12969 && config. parse_needs_matching_clang ( ln)
13070 {
131- props. ignore = Ignore :: Ignore ;
71+ props. ignore = true ;
13272 }
13373
13474 if !rustc_has_profiler_support && config. parse_needs_profiler_support ( ln) {
135- props. ignore = Ignore :: Ignore ;
75+ props. ignore = true ;
13676 }
13777
13878 if !rustc_has_sanitizer_support && config. parse_needs_sanitizer_support ( ln) {
139- props. ignore = Ignore :: Ignore ;
79+ props. ignore = true ;
14080 }
14181
14282 if config. target == "wasm32-unknown-unknown" && config. parse_check_run_results ( ln) {
143- props. ignore = Ignore :: Ignore ;
83+ props. ignore = true ;
14484 }
145- }
14685
147- if ( config. mode == common:: DebugInfoGdb || config. mode == common:: DebugInfoGdbLldb )
148- && props. ignore . can_run_gdb ( )
149- && ignore_gdb ( config, ln)
150- {
151- props. ignore = props. ignore . no_gdb ( ) ;
152- }
86+ if config. debugger == Some ( Debugger :: Gdb ) && ignore_gdb ( config, ln) {
87+ props. ignore = true ;
88+ }
15389
154- if ( config. mode == common:: DebugInfoLldb || config. mode == common:: DebugInfoGdbLldb )
155- && props. ignore . can_run_lldb ( )
156- && ignore_lldb ( config, ln)
157- {
158- props. ignore = props. ignore . no_lldb ( ) ;
90+ if config. debugger == Some ( Debugger :: Lldb ) && ignore_lldb ( config, ln) {
91+ props. ignore = true ;
92+ }
15993 }
16094
16195 if let Some ( s) = config. parse_aux_build ( ln) {
@@ -881,70 +815,37 @@ impl Config {
881815 /// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86`
882816 /// or `normalize-stderr-32bit`.
883817 fn parse_cfg_name_directive ( & self , line : & str , prefix : & str ) -> ParsedNameDirective {
884- if line. starts_with ( prefix) && line. as_bytes ( ) . get ( prefix. len ( ) ) == Some ( & b'-' ) {
885- let name = line[ prefix. len ( ) + 1 ..] . split ( & [ ':' , ' ' ] [ ..] ) . next ( ) . unwrap ( ) ;
886-
887- if name == "test" ||
888- & self . target == name || // triple
889- util:: matches_os ( & self . target , name) || // target
890- util:: matches_env ( & self . target , name) || // env
891- name == util:: get_arch ( & self . target ) || // architecture
892- name == util:: get_pointer_width ( & self . target ) || // pointer width
893- name == self . stage_id . split ( '-' ) . next ( ) . unwrap ( ) || // stage
894- ( self . target != self . host && name == "cross-compile" ) ||
895- match self . compare_mode {
896- Some ( CompareMode :: Nll ) => name == "compare-mode-nll" ,
897- Some ( CompareMode :: Polonius ) => name == "compare-mode-polonius" ,
898- None => false ,
899- } ||
900- ( cfg ! ( debug_assertions) && name == "debug" )
901- {
902- ParsedNameDirective :: Match
903- } else {
904- match self . mode {
905- common:: DebugInfoGdbLldb => {
906- if name == "gdb" {
907- ParsedNameDirective :: MatchGdb
908- } else if name == "lldb" {
909- ParsedNameDirective :: MatchLldb
910- } else {
911- ParsedNameDirective :: NoMatch
912- }
913- }
914- common:: DebugInfoCdb => {
915- if name == "cdb" {
916- ParsedNameDirective :: Match
917- } else {
918- ParsedNameDirective :: NoMatch
919- }
920- }
921- common:: DebugInfoGdb => {
922- if name == "gdb" {
923- ParsedNameDirective :: Match
924- } else {
925- ParsedNameDirective :: NoMatch
926- }
927- }
928- common:: DebugInfoLldb => {
929- if name == "lldb" {
930- ParsedNameDirective :: Match
931- } else {
932- ParsedNameDirective :: NoMatch
933- }
934- }
935- common:: Pretty => {
936- if name == "pretty" {
937- ParsedNameDirective :: Match
938- } else {
939- ParsedNameDirective :: NoMatch
940- }
941- }
942- _ => ParsedNameDirective :: NoMatch ,
943- }
944- }
945- } else {
946- ParsedNameDirective :: NoMatch
818+ if !line. as_bytes ( ) . starts_with ( prefix. as_bytes ( ) ) {
819+ return ParsedNameDirective :: NoMatch ;
820+ }
821+ if line. as_bytes ( ) . get ( prefix. len ( ) ) != Some ( & b'-' ) {
822+ return ParsedNameDirective :: NoMatch ;
947823 }
824+
825+ let name = line[ prefix. len ( ) + 1 ..] . split ( & [ ':' , ' ' ] [ ..] ) . next ( ) . unwrap ( ) ;
826+
827+ let is_match = name == "test" ||
828+ & self . target == name || // triple
829+ util:: matches_os ( & self . target , name) || // target
830+ util:: matches_env ( & self . target , name) || // env
831+ name == util:: get_arch ( & self . target ) || // architecture
832+ name == util:: get_pointer_width ( & self . target ) || // pointer width
833+ name == self . stage_id . split ( '-' ) . next ( ) . unwrap ( ) || // stage
834+ ( self . target != self . host && name == "cross-compile" ) ||
835+ match self . compare_mode {
836+ Some ( CompareMode :: Nll ) => name == "compare-mode-nll" ,
837+ Some ( CompareMode :: Polonius ) => name == "compare-mode-polonius" ,
838+ None => false ,
839+ } ||
840+ ( cfg ! ( debug_assertions) && name == "debug" ) ||
841+ match self . debugger {
842+ Some ( Debugger :: Cdb ) => name == "cdb" ,
843+ Some ( Debugger :: Gdb ) => name == "gdb" ,
844+ Some ( Debugger :: Lldb ) => name == "lldb" ,
845+ None => false ,
846+ } ;
847+
848+ if is_match { ParsedNameDirective :: Match } else { ParsedNameDirective :: NoMatch }
948849 }
949850
950851 fn has_cfg_prefix ( & self , line : & str , prefix : & str ) -> bool {
0 commit comments