@@ -7,7 +7,7 @@ use crate::runner::test::detect_broken;
7
7
use crate :: runner:: { test, RunnerState } ;
8
8
use crate :: toolchain:: Toolchain ;
9
9
use crate :: utils;
10
- use rustwide:: { BuildDirectory , Workspace } ;
10
+ use rustwide:: { Build , BuildDirectory , Workspace } ;
11
11
use std:: sync:: Mutex ;
12
12
13
13
use rustwide:: logging:: { self , LogStorage } ;
@@ -170,88 +170,100 @@ impl Task {
170
170
db : & ' ctx DB ,
171
171
state : & ' ctx RunnerState ,
172
172
) -> Fallible < ( ) > {
173
- match self . step {
174
- TaskStep :: Cleanup => {
175
- // Remove stored logs
176
- state. lock ( ) . prepare_logs . remove ( & self . krate ) ;
177
- }
178
- TaskStep :: Prepare => {
179
- let storage = LogStorage :: from ( config) ;
180
- state
181
- . lock ( )
182
- . prepare_logs
183
- . insert ( self . krate . clone ( ) , storage. clone ( ) ) ;
184
- logging:: capture ( & storage, || {
185
- let rustwide_crate = self . krate . to_rustwide ( ) ;
186
- detect_broken ( rustwide_crate. fetch ( workspace) ) ?;
187
-
188
- if let Crate :: GitHub ( repo) = & self . krate {
189
- if let Some ( sha) = rustwide_crate. git_commit ( workspace) {
190
- let updated = GitHubRepo {
191
- sha : Some ( sha) ,
192
- ..repo. clone ( )
193
- } ;
194
- db. update_crate_version (
195
- ex,
196
- & Crate :: GitHub ( repo. clone ( ) ) ,
197
- & Crate :: GitHub ( updated) ,
198
- )
199
- . with_context ( |_| {
200
- format ! ( "failed to record the sha of GitHub repo {}" , repo. slug( ) )
201
- } ) ?;
202
- } else {
203
- bail ! ( "unable to capture sha for {}" , repo. slug( ) ) ;
204
- }
205
- }
206
- Ok ( ( ) )
207
- } ) ?;
208
- }
209
- TaskStep :: BuildAndTest { ref tc, quiet } => {
210
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, quiet) ;
211
- test:: run_test ( "testing" , & ctx, test:: test_build_and_test) ?;
212
- }
213
- TaskStep :: BuildOnly { ref tc, quiet } => {
214
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, quiet) ;
215
- test:: run_test ( "building" , & ctx, test:: test_build_only) ?;
216
- }
217
- TaskStep :: CheckOnly { ref tc, quiet } => {
218
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, quiet) ;
219
- test:: run_test ( "checking" , & ctx, test:: test_check_only) ?;
220
- }
221
- TaskStep :: Clippy { ref tc, quiet } => {
222
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, quiet) ;
223
- test:: run_test ( "linting" , & ctx, test:: test_clippy_only) ?;
224
- }
225
- TaskStep :: Rustdoc { ref tc, quiet } => {
226
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, quiet) ;
227
- test:: run_test ( "documenting" , & ctx, test:: test_rustdoc) ?;
228
- }
229
- TaskStep :: UnstableFeatures { ref tc } => {
230
- let ctx = TaskCtx :: new ( build_dir, config, db, ex, tc, & self . krate , state, false ) ;
231
- test:: run_test (
173
+ let ( action, test, toolchain, quiet) : ( _ , fn ( & TaskCtx < _ > , & Build , & _) -> _ , _ , _ ) =
174
+ match self . step {
175
+ TaskStep :: BuildAndTest { ref tc, quiet } => {
176
+ ( "testing" , test:: test_build_and_test, tc, quiet)
177
+ }
178
+ TaskStep :: BuildOnly { ref tc, quiet } => {
179
+ ( "building" , test:: test_build_only, tc, quiet)
180
+ }
181
+ TaskStep :: CheckOnly { ref tc, quiet } => {
182
+ ( "checking" , test:: test_check_only, tc, quiet)
183
+ }
184
+ TaskStep :: Clippy { ref tc, quiet } => {
185
+ ( "linting" , test:: test_clippy_only, tc, quiet)
186
+ }
187
+ TaskStep :: Rustdoc { ref tc, quiet } => {
188
+ ( "documenting" , test:: test_rustdoc, tc, quiet)
189
+ }
190
+ TaskStep :: UnstableFeatures { ref tc } => (
232
191
"checking unstable" ,
233
- & ctx,
234
192
crate :: runner:: unstable_features:: find_unstable_features,
235
- ) ?;
236
- }
237
- TaskStep :: Skip { ref tc } => {
238
- // If a skipped crate is somehow sent to the agent (for example, when a crate was
239
- // added to the experiment and *then* blacklisted) report the crate as skipped
240
- // instead of silently ignoring it.
241
- db. record_result (
242
- ex,
243
193
tc,
244
- & self . krate ,
245
- None ,
246
- config,
247
- EncodingType :: Plain ,
248
- || {
249
- warn ! ( "crate skipped" ) ;
250
- Ok ( TestResult :: Skipped )
251
- } ,
252
- ) ?;
253
- }
254
- }
194
+ false ,
195
+ ) ,
196
+ TaskStep :: Cleanup => {
197
+ // Remove stored logs
198
+ state. lock ( ) . prepare_logs . remove ( & self . krate ) ;
199
+ return Ok ( ( ) ) ;
200
+ }
201
+ TaskStep :: Prepare => {
202
+ let storage = LogStorage :: from ( config) ;
203
+ state
204
+ . lock ( )
205
+ . prepare_logs
206
+ . insert ( self . krate . clone ( ) , storage. clone ( ) ) ;
207
+ logging:: capture ( & storage, || {
208
+ let rustwide_crate = self . krate . to_rustwide ( ) ;
209
+ detect_broken ( rustwide_crate. fetch ( workspace) ) ?;
210
+
211
+ if let Crate :: GitHub ( repo) = & self . krate {
212
+ if let Some ( sha) = rustwide_crate. git_commit ( workspace) {
213
+ let updated = GitHubRepo {
214
+ sha : Some ( sha) ,
215
+ ..repo. clone ( )
216
+ } ;
217
+ db. update_crate_version (
218
+ ex,
219
+ & Crate :: GitHub ( repo. clone ( ) ) ,
220
+ & Crate :: GitHub ( updated) ,
221
+ )
222
+ . with_context ( |_| {
223
+ format ! (
224
+ "failed to record the sha of GitHub repo {}" ,
225
+ repo. slug( )
226
+ )
227
+ } ) ?;
228
+ } else {
229
+ bail ! ( "unable to capture sha for {}" , repo. slug( ) ) ;
230
+ }
231
+ }
232
+ Ok ( ( ) )
233
+ } ) ?;
234
+ return Ok ( ( ) ) ;
235
+ }
236
+ TaskStep :: Skip { ref tc } => {
237
+ // If a skipped crate is somehow sent to the agent (for example, when a crate was
238
+ // added to the experiment and *then* blacklisted) report the crate as skipped
239
+ // instead of silently ignoring it.
240
+ db. record_result (
241
+ ex,
242
+ tc,
243
+ & self . krate ,
244
+ None ,
245
+ config,
246
+ EncodingType :: Plain ,
247
+ || {
248
+ warn ! ( "crate skipped" ) ;
249
+ Ok ( TestResult :: Skipped )
250
+ } ,
251
+ ) ?;
252
+ return Ok ( ( ) ) ;
253
+ }
254
+ } ;
255
+
256
+ let ctx = TaskCtx :: new (
257
+ build_dir,
258
+ config,
259
+ db,
260
+ ex,
261
+ toolchain,
262
+ & self . krate ,
263
+ state,
264
+ quiet,
265
+ ) ;
266
+ test:: run_test ( action, & ctx, test) ?;
255
267
256
268
Ok ( ( ) )
257
269
}
0 commit comments