@@ -228,7 +228,7 @@ impl Step for HtmlCheck {
228
228
/// order to test cargo.
229
229
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
230
230
pub struct Cargotest {
231
- stage : u32 ,
231
+ build_compiler : Compiler ,
232
232
host : TargetSelection ,
233
233
}
234
234
@@ -241,17 +241,26 @@ impl Step for Cargotest {
241
241
}
242
242
243
243
fn make_run ( run : RunConfig < ' _ > ) {
244
- run. builder . ensure ( Cargotest { stage : run. builder . top_stage , host : run. target } ) ;
244
+ // FIXME: support testing stage 0 cargo?
245
+ assert ! ( run. builder. top_stage > 0 ) ;
246
+ run. builder . ensure ( Cargotest {
247
+ build_compiler : run. builder . compiler ( run. builder . top_stage - 1 , run. target ) ,
248
+ host : run. target ,
249
+ } ) ;
245
250
}
246
251
247
252
/// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
248
253
///
249
254
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
250
255
/// test` to ensure that we don't regress the test suites there.
251
256
fn run ( self , builder : & Builder < ' _ > ) {
252
- let compiler = builder. compiler ( self . stage , self . host ) ;
253
- builder. ensure ( compile:: Rustc :: new ( compiler, compiler. host ) ) ;
254
- let cargo = builder. ensure ( tool:: Cargo { compiler, target : compiler. host } ) ;
257
+ // Here we need to ensure that we run cargo with an in-tree compiler, because we test
258
+ // both their behavior together.
259
+ // We can build cargo with the earlier stage compiler though.
260
+ let cargo =
261
+ builder. ensure ( tool:: Cargo { compiler : self . build_compiler , target : self . host } ) ;
262
+ let tested_compiler = builder. compiler ( self . build_compiler . stage + 1 , self . host ) ;
263
+ builder. std ( tested_compiler, self . host ) ;
255
264
256
265
// Note that this is a short, cryptic, and not scoped directory name. This
257
266
// is currently to minimize the length of path on Windows where we otherwise
@@ -264,17 +273,21 @@ impl Step for Cargotest {
264
273
cmd. arg ( & cargo. tool_path )
265
274
. arg ( & out_dir)
266
275
. args ( builder. config . test_args ( ) )
267
- . env ( "RUSTC" , builder. rustc ( compiler ) )
268
- . env ( "RUSTDOC" , builder. rustdoc_for_compiler ( compiler ) ) ;
276
+ . env ( "RUSTC" , builder. rustc ( tested_compiler ) )
277
+ . env ( "RUSTDOC" , builder. rustdoc_for_compiler ( tested_compiler ) ) ;
269
278
add_rustdoc_cargo_linker_args (
270
279
& mut cmd,
271
280
builder,
272
- compiler . host ,
281
+ tested_compiler . host ,
273
282
LldThreads :: No ,
274
- compiler . stage ,
283
+ tested_compiler . stage ,
275
284
) ;
276
285
cmd. delay_failure ( ) . run ( builder) ;
277
286
}
287
+
288
+ fn metadata ( & self ) -> Option < StepMetadata > {
289
+ Some ( StepMetadata :: test ( "cargotest" , self . host ) . stage ( self . build_compiler . stage + 1 ) )
290
+ }
278
291
}
279
292
280
293
/// Runs `cargo test` for cargo itself.
0 commit comments