@@ -54,80 +54,101 @@ pub struct TestProps {
54
54
55
55
// Load any test directives embedded in the file
56
56
pub fn load_props ( testfile : & Path ) -> TestProps {
57
- let mut error_patterns = Vec :: new ( ) ;
58
- let mut aux_builds = Vec :: new ( ) ;
59
- let mut exec_env = Vec :: new ( ) ;
60
- let mut compile_flags = None ;
61
- let mut run_flags = None ;
62
- let mut pp_exact = None ;
63
- let mut check_lines = Vec :: new ( ) ;
64
- let mut build_aux_docs = false ;
65
- let mut force_host = false ;
66
- let mut check_stdout = false ;
67
- let mut no_prefer_dynamic = false ;
68
- let mut pretty_expanded = false ;
69
- let mut pretty_mode = None ;
70
- let mut pretty_compare_only = false ;
71
- let mut forbid_output = Vec :: new ( ) ;
57
+ let error_patterns = Vec :: new ( ) ;
58
+ let aux_builds = Vec :: new ( ) ;
59
+ let exec_env = Vec :: new ( ) ;
60
+ let compile_flags = None ;
61
+ let run_flags = None ;
62
+ let pp_exact = None ;
63
+ let check_lines = Vec :: new ( ) ;
64
+ let build_aux_docs = false ;
65
+ let force_host = false ;
66
+ let check_stdout = false ;
67
+ let no_prefer_dynamic = false ;
68
+ let pretty_expanded = false ;
69
+ let pretty_compare_only = false ;
70
+ let forbid_output = Vec :: new ( ) ;
71
+ let mut props = TestProps {
72
+ error_patterns : error_patterns,
73
+ compile_flags : compile_flags,
74
+ run_flags : run_flags,
75
+ pp_exact : pp_exact,
76
+ aux_builds : aux_builds,
77
+ exec_env : exec_env,
78
+ check_lines : check_lines,
79
+ build_aux_docs : build_aux_docs,
80
+ force_host : force_host,
81
+ check_stdout : check_stdout,
82
+ no_prefer_dynamic : no_prefer_dynamic,
83
+ pretty_expanded : pretty_expanded,
84
+ pretty_mode : format ! ( "normal" ) ,
85
+ pretty_compare_only : pretty_compare_only,
86
+ forbid_output : forbid_output,
87
+ } ;
88
+ load_props_into ( & mut props, testfile) ;
89
+ props
90
+ }
91
+
92
+ pub fn load_props_into ( props : & mut TestProps , testfile : & Path ) {
72
93
iter_header ( testfile, & mut |ln| {
73
94
if let Some ( ep) = parse_error_pattern ( ln) {
74
- error_patterns. push ( ep) ;
95
+ props . error_patterns . push ( ep) ;
75
96
}
76
97
77
- if compile_flags. is_none ( ) {
78
- compile_flags = parse_compile_flags ( ln) ;
98
+ if props . compile_flags . is_none ( ) {
99
+ props . compile_flags = parse_compile_flags ( ln) ;
79
100
}
80
101
81
- if run_flags. is_none ( ) {
82
- run_flags = parse_run_flags ( ln) ;
102
+ if props . run_flags . is_none ( ) {
103
+ props . run_flags = parse_run_flags ( ln) ;
83
104
}
84
105
85
- if pp_exact. is_none ( ) {
86
- pp_exact = parse_pp_exact ( ln, testfile) ;
106
+ if props . pp_exact . is_none ( ) {
107
+ props . pp_exact = parse_pp_exact ( ln, testfile) ;
87
108
}
88
109
89
- if !build_aux_docs {
90
- build_aux_docs = parse_build_aux_docs ( ln) ;
110
+ if !props . build_aux_docs {
111
+ props . build_aux_docs = parse_build_aux_docs ( ln) ;
91
112
}
92
113
93
- if !force_host {
94
- force_host = parse_force_host ( ln) ;
114
+ if !props . force_host {
115
+ props . force_host = parse_force_host ( ln) ;
95
116
}
96
117
97
- if !check_stdout {
98
- check_stdout = parse_check_stdout ( ln) ;
118
+ if !props . check_stdout {
119
+ props . check_stdout = parse_check_stdout ( ln) ;
99
120
}
100
121
101
- if !no_prefer_dynamic {
102
- no_prefer_dynamic = parse_no_prefer_dynamic ( ln) ;
122
+ if !props . no_prefer_dynamic {
123
+ props . no_prefer_dynamic = parse_no_prefer_dynamic ( ln) ;
103
124
}
104
125
105
- if !pretty_expanded {
106
- pretty_expanded = parse_pretty_expanded ( ln) ;
126
+ if !props . pretty_expanded {
127
+ props . pretty_expanded = parse_pretty_expanded ( ln) ;
107
128
}
108
129
109
- if pretty_mode . is_none ( ) {
110
- pretty_mode = parse_pretty_mode ( ln ) ;
130
+ if let Some ( m ) = parse_pretty_mode ( ln ) {
131
+ props . pretty_mode = m ;
111
132
}
112
133
113
- if !pretty_compare_only {
114
- pretty_compare_only = parse_pretty_compare_only ( ln) ;
134
+ if !props . pretty_compare_only {
135
+ props . pretty_compare_only = parse_pretty_compare_only ( ln) ;
115
136
}
116
137
117
138
if let Some ( ab) = parse_aux_build ( ln) {
118
- aux_builds. push ( ab) ;
139
+ props . aux_builds . push ( ab) ;
119
140
}
120
141
121
142
if let Some ( ee) = parse_exec_env ( ln) {
122
- exec_env. push ( ee) ;
143
+ props . exec_env . push ( ee) ;
123
144
}
124
145
125
146
if let Some ( cl) = parse_check_line ( ln) {
126
- check_lines. push ( cl) ;
147
+ props . check_lines . push ( cl) ;
127
148
}
128
149
129
150
if let Some ( of) = parse_forbid_output ( ln) {
130
- forbid_output. push ( of) ;
151
+ props . forbid_output . push ( of) ;
131
152
}
132
153
133
154
true
@@ -136,30 +157,12 @@ pub fn load_props(testfile: &Path) -> TestProps {
136
157
for key in vec ! [ "RUST_TEST_NOCAPTURE" , "RUST_TEST_THREADS" ] {
137
158
match env:: var ( key) {
138
159
Ok ( val) =>
139
- if exec_env. iter ( ) . find ( |& & ( ref x, _) | * x == key) . is_none ( ) {
140
- exec_env. push ( ( key. to_owned ( ) , val) )
160
+ if props . exec_env . iter ( ) . find ( |& & ( ref x, _) | * x == key) . is_none ( ) {
161
+ props . exec_env . push ( ( key. to_owned ( ) , val) )
141
162
} ,
142
163
Err ( ..) => { }
143
164
}
144
165
}
145
-
146
- TestProps {
147
- error_patterns : error_patterns,
148
- compile_flags : compile_flags,
149
- run_flags : run_flags,
150
- pp_exact : pp_exact,
151
- aux_builds : aux_builds,
152
- exec_env : exec_env,
153
- check_lines : check_lines,
154
- build_aux_docs : build_aux_docs,
155
- force_host : force_host,
156
- check_stdout : check_stdout,
157
- no_prefer_dynamic : no_prefer_dynamic,
158
- pretty_expanded : pretty_expanded,
159
- pretty_mode : pretty_mode. unwrap_or ( "normal" . to_owned ( ) ) ,
160
- pretty_compare_only : pretty_compare_only,
161
- forbid_output : forbid_output,
162
- }
163
166
}
164
167
165
168
pub fn is_test_ignored ( config : & Config , testfile : & Path ) -> bool {
@@ -253,8 +256,7 @@ fn iter_header(testfile: &Path, it: &mut FnMut(&str) -> bool) -> bool {
253
256
// with a warm page cache. Maybe with a cold one.
254
257
let ln = ln. unwrap ( ) ;
255
258
let ln = ln. trim ( ) ;
256
- if ln. starts_with ( "fn" ) ||
257
- ln. starts_with ( "mod" ) {
259
+ if ln. starts_with ( "fn" ) || ln. starts_with ( "mod" ) {
258
260
return true ;
259
261
} else if ln. starts_with ( "//" ) {
260
262
if !it ( & ln[ 2 ..] ) {
0 commit comments