@@ -19,10 +19,62 @@ use util;
19
19
20
20
use extract_gdb_version;
21
21
22
+ /// Whether to ignore the test.
23
+ #[ derive( Clone , Copy , PartialEq , Debug ) ]
24
+ pub enum Ignore {
25
+ /// Run it.
26
+ Run ,
27
+ /// Ignore it totally.
28
+ Ignore ,
29
+ /// Ignore only the gdb test, but run the lldb test.
30
+ IgnoreGdb ,
31
+ /// Ignore only the lldb test, but run the gdb test.
32
+ IgnoreLldb ,
33
+ }
34
+
35
+ impl Ignore {
36
+ pub fn can_run_gdb ( & self ) -> bool {
37
+ * self == Ignore :: Run || * self == Ignore :: IgnoreLldb
38
+ }
39
+
40
+ pub fn can_run_lldb ( & self ) -> bool {
41
+ * self == Ignore :: Run || * self == Ignore :: IgnoreGdb
42
+ }
43
+
44
+ pub fn no_gdb ( & self ) -> Ignore {
45
+ match * self {
46
+ Ignore :: Run => Ignore :: IgnoreGdb ,
47
+ Ignore :: IgnoreGdb => Ignore :: IgnoreGdb ,
48
+ _ => Ignore :: Ignore ,
49
+ }
50
+ }
51
+
52
+ pub fn no_lldb ( & self ) -> Ignore {
53
+ match * self {
54
+ Ignore :: Run => Ignore :: IgnoreLldb ,
55
+ Ignore :: IgnoreLldb => Ignore :: IgnoreLldb ,
56
+ _ => Ignore :: Ignore ,
57
+ }
58
+ }
59
+ }
60
+
61
+ /// The result of parse_cfg_name_directive.
62
+ #[ derive( Clone , Copy , PartialEq , Debug ) ]
63
+ enum ParsedNameDirective {
64
+ /// No match.
65
+ NoMatch ,
66
+ /// Match.
67
+ Match ,
68
+ /// Mode was DebugInfoBoth and this matched gdb.
69
+ MatchGdb ,
70
+ /// Mode was DebugInfoBoth and this matched lldb.
71
+ MatchLldb ,
72
+ }
73
+
22
74
/// Properties which must be known very early, before actually running
23
75
/// the test.
24
76
pub struct EarlyProps {
25
- pub ignore : bool ,
77
+ pub ignore : Ignore ,
26
78
pub should_fail : bool ,
27
79
pub aux : Vec < String > ,
28
80
pub revisions : Vec < String > ,
@@ -31,20 +83,55 @@ pub struct EarlyProps {
31
83
impl EarlyProps {
32
84
pub fn from_file ( config : & Config , testfile : & Path ) -> Self {
33
85
let mut props = EarlyProps {
34
- ignore : false ,
86
+ ignore : Ignore :: Run ,
35
87
should_fail : false ,
36
88
aux : Vec :: new ( ) ,
37
89
revisions : vec ! [ ] ,
38
90
} ;
39
91
92
+ if config. mode == common:: DebugInfoBoth {
93
+ if config. lldb_python_dir . is_none ( ) {
94
+ props. ignore = props. ignore . no_lldb ( ) ;
95
+ }
96
+ if config. gdb_version . is_none ( ) {
97
+ props. ignore = props. ignore . no_gdb ( ) ;
98
+ }
99
+ }
100
+
40
101
iter_header ( testfile, None , & mut |ln| {
41
102
// we should check if any only-<platform> exists and if it exists
42
103
// and does not matches the current platform, skip the test
43
- props. ignore = props. ignore || config. parse_cfg_name_directive ( ln, "ignore" )
44
- || ( config. has_cfg_prefix ( ln, "only" )
45
- && !config. parse_cfg_name_directive ( ln, "only" ) )
46
- || ignore_gdb ( config, ln) || ignore_lldb ( config, ln)
47
- || ignore_llvm ( config, ln) ;
104
+ if props. ignore != Ignore :: Ignore {
105
+ props. ignore = match config. parse_cfg_name_directive ( ln, "ignore" ) {
106
+ ParsedNameDirective :: Match => Ignore :: Ignore ,
107
+ ParsedNameDirective :: NoMatch => props. ignore ,
108
+ ParsedNameDirective :: MatchGdb => props. ignore . no_gdb ( ) ,
109
+ ParsedNameDirective :: MatchLldb => props. ignore . no_lldb ( ) ,
110
+ } ;
111
+
112
+ if config. has_cfg_prefix ( ln, "only" ) {
113
+ props. ignore = match config. parse_cfg_name_directive ( ln, "only" ) {
114
+ ParsedNameDirective :: Match => props. ignore ,
115
+ ParsedNameDirective :: NoMatch => Ignore :: Ignore ,
116
+ ParsedNameDirective :: MatchLldb => props. ignore . no_gdb ( ) ,
117
+ ParsedNameDirective :: MatchGdb => props. ignore . no_lldb ( ) ,
118
+ } ;
119
+ }
120
+
121
+ if ignore_llvm ( config, ln) {
122
+ props. ignore = Ignore :: Ignore ;
123
+ }
124
+ }
125
+
126
+ if ( config. mode == common:: DebugInfoGdb || config. mode == common:: DebugInfoBoth ) &&
127
+ props. ignore . can_run_gdb ( ) && ignore_gdb ( config, ln) {
128
+ props. ignore = props. ignore . no_gdb ( ) ;
129
+ }
130
+
131
+ if ( config. mode == common:: DebugInfoLldb || config. mode == common:: DebugInfoBoth ) &&
132
+ props. ignore . can_run_lldb ( ) && ignore_lldb ( config, ln) {
133
+ props. ignore = props. ignore . no_lldb ( ) ;
134
+ }
48
135
49
136
if let Some ( s) = config. parse_aux_build ( ln) {
50
137
props. aux . push ( s) ;
@@ -60,10 +147,6 @@ impl EarlyProps {
60
147
return props;
61
148
62
149
fn ignore_gdb ( config : & Config , line : & str ) -> bool {
63
- if config. mode != common:: DebugInfoGdb {
64
- return false ;
65
- }
66
-
67
150
if let Some ( actual_version) = config. gdb_version {
68
151
if line. starts_with ( "min-gdb-version" ) {
69
152
let ( start_ver, end_ver) = extract_gdb_version_range ( line) ;
@@ -120,10 +203,6 @@ impl EarlyProps {
120
203
}
121
204
122
205
fn ignore_lldb ( config : & Config , line : & str ) -> bool {
123
- if config. mode != common:: DebugInfoLldb {
124
- return false ;
125
- }
126
-
127
206
if let Some ( ref actual_version) = config. lldb_version {
128
207
if line. starts_with ( "min-lldb-version" ) {
129
208
let min_version = line. trim_right ( )
@@ -604,7 +683,7 @@ impl Config {
604
683
}
605
684
606
685
fn parse_custom_normalization ( & self , mut line : & str , prefix : & str ) -> Option < ( String , String ) > {
607
- if self . parse_cfg_name_directive ( line, prefix) {
686
+ if self . parse_cfg_name_directive ( line, prefix) == ParsedNameDirective :: Match {
608
687
let from = match parse_normalization_string ( & mut line) {
609
688
Some ( s) => s,
610
689
None => return None ,
@@ -620,35 +699,59 @@ impl Config {
620
699
}
621
700
622
701
/// Parses a name-value directive which contains config-specific information, e.g. `ignore-x86`
623
- /// or `normalize-stderr-32bit`. Returns `true` if the line matches it.
624
- fn parse_cfg_name_directive ( & self , line : & str , prefix : & str ) -> bool {
702
+ /// or `normalize-stderr-32bit`.
703
+ fn parse_cfg_name_directive ( & self , line : & str , prefix : & str ) -> ParsedNameDirective {
625
704
if line. starts_with ( prefix) && line. as_bytes ( ) . get ( prefix. len ( ) ) == Some ( & b'-' ) {
626
705
let name = line[ prefix. len ( ) + 1 ..]
627
706
. split ( & [ ':' , ' ' ] [ ..] )
628
707
. next ( )
629
708
. unwrap ( ) ;
630
709
631
- name == "test" ||
710
+ if name == "test" ||
632
711
util:: matches_os ( & self . target , name) || // target
633
712
name == util:: get_arch ( & self . target ) || // architecture
634
713
name == util:: get_pointer_width ( & self . target ) || // pointer width
635
714
name == self . stage_id . split ( '-' ) . next ( ) . unwrap ( ) || // stage
636
715
Some ( name) == util:: get_env ( & self . target ) || // env
637
- match self . mode {
638
- common:: DebugInfoGdb => name == "gdb" ,
639
- common:: DebugInfoLldb => name == "lldb" ,
640
- common:: Pretty => name == "pretty" ,
641
- _ => false ,
642
- } ||
643
716
( self . target != self . host && name == "cross-compile" ) ||
644
717
match self . compare_mode {
645
718
Some ( CompareMode :: Nll ) => name == "compare-mode-nll" ,
646
719
Some ( CompareMode :: Polonius ) => name == "compare-mode-polonius" ,
647
720
None => false ,
648
721
} ||
649
- ( cfg ! ( debug_assertions) && name == "debug" )
722
+ ( cfg ! ( debug_assertions) && name == "debug" ) {
723
+ ParsedNameDirective :: Match
724
+ } else {
725
+ match self . mode {
726
+ common:: DebugInfoBoth => {
727
+ if name == "gdb" {
728
+ ParsedNameDirective :: MatchGdb
729
+ } else if name == "lldb" {
730
+ ParsedNameDirective :: MatchLldb
731
+ } else {
732
+ ParsedNameDirective :: NoMatch
733
+ }
734
+ } ,
735
+ common:: DebugInfoGdb => if name == "gdb" {
736
+ ParsedNameDirective :: Match
737
+ } else {
738
+ ParsedNameDirective :: NoMatch
739
+ } ,
740
+ common:: DebugInfoLldb => if name == "lldb" {
741
+ ParsedNameDirective :: Match
742
+ } else {
743
+ ParsedNameDirective :: NoMatch
744
+ } ,
745
+ common:: Pretty => if name == "pretty" {
746
+ ParsedNameDirective :: Match
747
+ } else {
748
+ ParsedNameDirective :: NoMatch
749
+ } ,
750
+ _ => ParsedNameDirective :: NoMatch ,
751
+ }
752
+ }
650
753
} else {
651
- false
754
+ ParsedNameDirective :: NoMatch
652
755
}
653
756
}
654
757
0 commit comments