@@ -6,69 +6,26 @@ use std::path::{Path, PathBuf};
6
6
7
7
use log:: * ;
8
8
9
- use crate :: common:: { self , CompareMode , Config , FailMode , Mode , PassMode } ;
9
+ use crate :: common:: { CompareMode , Config , Debugger , FailMode , Mode , PassMode } ;
10
10
use crate :: extract_gdb_version;
11
11
use crate :: util;
12
12
13
13
#[ cfg( test) ]
14
14
mod tests;
15
15
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
-
55
16
/// The result of parse_cfg_name_directive.
56
17
#[ derive( Clone , Copy , PartialEq , Debug ) ]
57
18
enum ParsedNameDirective {
58
19
/// No match.
59
20
NoMatch ,
60
21
/// Match.
61
22
Match ,
62
- /// Mode was DebugInfoGdbLldb and this matched gdb.
63
- MatchGdb ,
64
- /// Mode was DebugInfoGdbLldb and this matched lldb.
65
- MatchLldb ,
66
23
}
67
24
68
25
/// Properties which must be known very early, before actually running
69
26
/// the test.
70
27
pub struct EarlyProps {
71
- pub ignore : Ignore ,
28
+ pub ignore : bool ,
72
29
pub should_fail : bool ,
73
30
pub aux : Vec < String > ,
74
31
pub aux_crate : Vec < ( String , String ) > ,
@@ -78,84 +35,61 @@ pub struct EarlyProps {
78
35
impl EarlyProps {
79
36
pub fn from_file ( config : & Config , testfile : & Path ) -> Self {
80
37
let mut props = EarlyProps {
81
- ignore : Ignore :: Run ,
38
+ ignore : false ,
82
39
should_fail : false ,
83
40
aux : Vec :: new ( ) ,
84
41
aux_crate : Vec :: new ( ) ,
85
42
revisions : vec ! [ ] ,
86
43
} ;
87
44
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
-
101
45
let rustc_has_profiler_support = env:: var_os ( "RUSTC_PROFILER_SUPPORT" ) . is_some ( ) ;
102
46
let rustc_has_sanitizer_support = env:: var_os ( "RUSTC_SANITIZER_SUPPORT" ) . is_some ( ) ;
103
47
104
48
iter_header ( testfile, None , & mut |ln| {
105
49
// we should check if any only-<platform> exists and if it exists
106
50
// and does not matches the current platform, skip the test
107
- if props. ignore != Ignore :: Ignore {
51
+ if ! props. ignore {
108
52
props. ignore = match config. parse_cfg_name_directive ( ln, "ignore" ) {
109
- ParsedNameDirective :: Match => Ignore :: Ignore ,
53
+ ParsedNameDirective :: Match => true ,
110
54
ParsedNameDirective :: NoMatch => props. ignore ,
111
- ParsedNameDirective :: MatchGdb => props. ignore . no_gdb ( ) ,
112
- ParsedNameDirective :: MatchLldb => props. ignore . no_lldb ( ) ,
113
55
} ;
114
56
115
57
if config. has_cfg_prefix ( ln, "only" ) {
116
58
props. ignore = match config. parse_cfg_name_directive ( ln, "only" ) {
117
59
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 ,
121
61
} ;
122
62
}
123
63
124
64
if ignore_llvm ( config, ln) {
125
- props. ignore = Ignore :: Ignore ;
65
+ props. ignore = true ;
126
66
}
127
67
128
68
if config. run_clang_based_tests_with . is_none ( )
129
69
&& config. parse_needs_matching_clang ( ln)
130
70
{
131
- props. ignore = Ignore :: Ignore ;
71
+ props. ignore = true ;
132
72
}
133
73
134
74
if !rustc_has_profiler_support && config. parse_needs_profiler_support ( ln) {
135
- props. ignore = Ignore :: Ignore ;
75
+ props. ignore = true ;
136
76
}
137
77
138
78
if !rustc_has_sanitizer_support && config. parse_needs_sanitizer_support ( ln) {
139
- props. ignore = Ignore :: Ignore ;
79
+ props. ignore = true ;
140
80
}
141
81
142
82
if config. target == "wasm32-unknown-unknown" && config. parse_check_run_results ( ln) {
143
- props. ignore = Ignore :: Ignore ;
83
+ props. ignore = true ;
144
84
}
145
- }
146
85
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
+ }
153
89
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
+ }
159
93
}
160
94
161
95
if let Some ( s) = config. parse_aux_build ( ln) {
@@ -881,70 +815,37 @@ impl Config {
881
815
/// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86`
882
816
/// or `normalize-stderr-32bit`.
883
817
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 ;
947
823
}
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 }
948
849
}
949
850
950
851
fn has_cfg_prefix ( & self , line : & str , prefix : & str ) -> bool {
0 commit comments