Skip to content

Commit c46f42d

Browse files
committed
Clarify comments on Cargo (self-)test steps
1 parent 47da014 commit c46f42d

File tree

1 file changed

+14
-4
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+14
-4
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ impl Step for Cargotest {
250250
);
251251
exit!(1);
252252
}
253+
// We want to build cargo stage N (where N == top_stage), and rustc stage N,
254+
// and test both of these together.
255+
// So we need to get a build compiler stage N-1 to build the stage N components.
253256
run.builder.ensure(Cargotest {
254257
build_compiler: run.builder.compiler(run.builder.top_stage - 1, run.target),
255258
host: run.target,
@@ -261,9 +264,15 @@ impl Step for Cargotest {
261264
/// This tool in `src/tools` will check out a few Rust projects and run `cargo
262265
/// test` to ensure that we don't regress the test suites there.
263266
fn run(self, builder: &Builder<'_>) {
264-
// Here we need to ensure that we run cargo with an in-tree compiler, because we test
265-
// both their behavior together.
266-
// We can build cargo with the earlier stage compiler though.
267+
// cargotest's staging has several pieces:
268+
// consider ./x test cargotest --stage=2.
269+
//
270+
// The test goal is to exercise a (stage 2 cargo, stage 2 rustc) pair through a stage 2
271+
// cargotest tool.
272+
// To produce the stage 2 cargo and cargotest, we need to do so with the stage 1 rustc and std.
273+
// Importantly, the stage 2 rustc being tested (`tested_compiler`) via stage 2 cargotest is
274+
// the rustc built by an earlier stage 1 rustc (the build_compiler). These are two different
275+
// compilers!
267276
let cargo =
268277
builder.ensure(tool::Cargo::from_build_compiler(self.build_compiler, self.host));
269278
let tested_compiler = builder.compiler(self.build_compiler.stage + 1, self.host);
@@ -298,6 +307,7 @@ impl Step for Cargotest {
298307
}
299308

300309
/// Runs `cargo test` for cargo itself.
310+
/// We label these tests as "cargo self-tests".
301311
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
302312
pub struct Cargo {
303313
build_compiler: Compiler,
@@ -328,7 +338,7 @@ impl Step for Cargo {
328338

329339
/// Runs `cargo test` for `cargo` packaged with Rust.
330340
fn run(self, builder: &Builder<'_>) {
331-
// When we do a "stage 1 cargo test", it means that we test the stage 1 rustc
341+
// When we do a "stage 1 cargo self-test", it means that we test the stage 1 rustc
332342
// using stage 1 cargo. So we actually build cargo using the stage 0 compiler, and then
333343
// run its tests against the stage 1 compiler (called `tested_compiler` below).
334344
builder.ensure(tool::Cargo::from_build_compiler(self.build_compiler, self.host));

0 commit comments

Comments
 (0)