@@ -11,6 +11,35 @@ use std::fmt;
11
11
use toolchain:: Toolchain ;
12
12
use utils;
13
13
14
+ pub ( super ) struct TaskCtx < ' ctx , DB : WriteResults + ' ctx > {
15
+ pub ( super ) config : & ' ctx Config ,
16
+ pub ( super ) db : & ' ctx DB ,
17
+ pub ( super ) experiment : & ' ctx Experiment ,
18
+ pub ( super ) toolchain : & ' ctx Toolchain ,
19
+ pub ( super ) krate : & ' ctx Crate ,
20
+ pub ( super ) quiet : bool ,
21
+ }
22
+
23
+ impl < ' ctx , DB : WriteResults + ' ctx > TaskCtx < ' ctx , DB > {
24
+ fn new (
25
+ config : & ' ctx Config ,
26
+ db : & ' ctx DB ,
27
+ experiment : & ' ctx Experiment ,
28
+ toolchain : & ' ctx Toolchain ,
29
+ krate : & ' ctx Crate ,
30
+ quiet : bool ,
31
+ ) -> Self {
32
+ TaskCtx {
33
+ config,
34
+ db,
35
+ experiment,
36
+ toolchain,
37
+ krate,
38
+ quiet,
39
+ }
40
+ }
41
+ }
42
+
14
43
pub ( super ) enum TaskStep {
15
44
Prepare ,
16
45
Cleanup ,
@@ -127,123 +156,37 @@ impl Task {
127
156
for tc in & ex. toolchains {
128
157
let _ = utils:: fs:: remove_dir_all ( & dirs:: crate_source_dir ( ex, tc, & self . krate ) ) ;
129
158
}
130
- Ok ( ( ) )
131
159
}
132
160
TaskStep :: Prepare => {
133
161
let prepare = PrepareCrate :: new ( ex, & self . krate , config, db) ;
134
- prepare. prepare ( )
162
+ prepare. prepare ( ) ? ;
135
163
}
136
164
TaskStep :: BuildAndTest { ref tc, quiet } => {
137
- self . run_build_and_test ( config, ex, tc, db, quiet)
165
+ let ctx = TaskCtx :: new ( config, db, ex, tc, & self . krate , quiet) ;
166
+ test:: run_test ( "testing" , & ctx, test:: test_build_and_test) ?;
167
+ }
168
+ TaskStep :: BuildOnly { ref tc, quiet } => {
169
+ let ctx = TaskCtx :: new ( config, db, ex, tc, & self . krate , quiet) ;
170
+ test:: run_test ( "building" , & ctx, test:: test_build_only) ?;
171
+ }
172
+ TaskStep :: CheckOnly { ref tc, quiet } => {
173
+ let ctx = TaskCtx :: new ( config, db, ex, tc, & self . krate , quiet) ;
174
+ test:: run_test ( "checking" , & ctx, test:: test_check_only) ?;
175
+ }
176
+ TaskStep :: Rustdoc { ref tc, quiet } => {
177
+ let ctx = TaskCtx :: new ( config, db, ex, tc, & self . krate , quiet) ;
178
+ test:: run_test ( "documenting" , & ctx, test:: test_rustdoc) ?;
179
+ }
180
+ TaskStep :: UnstableFeatures { ref tc } => {
181
+ let ctx = TaskCtx :: new ( config, db, ex, tc, & self . krate , false ) ;
182
+ test:: run_test (
183
+ "checking unstable" ,
184
+ & ctx,
185
+ :: runner:: unstable_features:: find_unstable_features,
186
+ ) ?;
138
187
}
139
- TaskStep :: BuildOnly { ref tc, quiet } => self . run_build_only ( config, ex, tc, db, quiet) ,
140
- TaskStep :: CheckOnly { ref tc, quiet } => self . run_check_only ( config, ex, tc, db, quiet) ,
141
- TaskStep :: Rustdoc { ref tc, quiet } => self . run_rustdoc ( config, ex, tc, db, quiet) ,
142
- TaskStep :: UnstableFeatures { ref tc } => self . run_unstable_features ( config, ex, db, tc) ,
143
188
}
144
- }
145
-
146
- fn run_build_and_test < DB : WriteResults > (
147
- & self ,
148
- config : & Config ,
149
- ex : & Experiment ,
150
- tc : & Toolchain ,
151
- db : & DB ,
152
- quiet : bool ,
153
- ) -> Fallible < ( ) > {
154
- test:: run_test (
155
- config,
156
- "testing" ,
157
- ex,
158
- tc,
159
- & self . krate ,
160
- db,
161
- quiet,
162
- test:: test_build_and_test,
163
- )
164
- . map ( |_| ( ) )
165
- }
166
189
167
- fn run_build_only < DB : WriteResults > (
168
- & self ,
169
- config : & Config ,
170
- ex : & Experiment ,
171
- tc : & Toolchain ,
172
- db : & DB ,
173
- quiet : bool ,
174
- ) -> Fallible < ( ) > {
175
- test:: run_test (
176
- config,
177
- "testing" ,
178
- ex,
179
- tc,
180
- & self . krate ,
181
- db,
182
- quiet,
183
- test:: test_build_only,
184
- )
185
- . map ( |_| ( ) )
186
- }
187
-
188
- fn run_check_only < DB : WriteResults > (
189
- & self ,
190
- config : & Config ,
191
- ex : & Experiment ,
192
- tc : & Toolchain ,
193
- db : & DB ,
194
- quiet : bool ,
195
- ) -> Fallible < ( ) > {
196
- test:: run_test (
197
- config,
198
- "checking" ,
199
- ex,
200
- tc,
201
- & self . krate ,
202
- db,
203
- quiet,
204
- test:: test_check_only,
205
- )
206
- . map ( |_| ( ) )
207
- }
208
-
209
- fn run_rustdoc < DB : WriteResults > (
210
- & self ,
211
- config : & Config ,
212
- ex : & Experiment ,
213
- tc : & Toolchain ,
214
- db : & DB ,
215
- quiet : bool ,
216
- ) -> Fallible < ( ) > {
217
- test:: run_test (
218
- config,
219
- "documenting" ,
220
- ex,
221
- tc,
222
- & self . krate ,
223
- db,
224
- quiet,
225
- test:: test_rustdoc,
226
- )
227
- . map ( |_| ( ) )
228
- }
229
-
230
- fn run_unstable_features < DB : WriteResults > (
231
- & self ,
232
- config : & Config ,
233
- ex : & Experiment ,
234
- db : & DB ,
235
- tc : & Toolchain ,
236
- ) -> Fallible < ( ) > {
237
- test:: run_test (
238
- config,
239
- "checking" ,
240
- ex,
241
- tc,
242
- & self . krate ,
243
- db,
244
- false ,
245
- :: runner:: unstable_features:: find_unstable_features,
246
- )
247
- . map ( |_| ( ) )
190
+ Ok ( ( ) )
248
191
}
249
192
}
0 commit comments