Skip to content

Commit 07a2995

Browse files
authored
Rollup merge of #135231 - Zalathar:test-step-notes, r=jieyouxu
bootstrap: Add more comments to some of the test steps Some of the test steps have names that don't clearly indicate what they actually do. While there is ongoing experimental work to actually rename the steps (e.g. #135071), that's dependent on figuring out what the new names should actually be. In the meantime, we can still improve things by adding comments to help describe the steps, which will remain useful even after any renaming.
2 parents 29c17fc + ceabc95 commit 07a2995

File tree

1 file changed

+43
-0
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+43
-0
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::{CLang, DocTests, GitRepo, Mode, PathSet, envify};
3131

3232
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
3333

34+
/// Runs `cargo test` on various internal tools used by bootstrap.
3435
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3536
pub struct CrateBootstrap {
3637
path: PathBuf,
@@ -43,13 +44,21 @@ impl Step for CrateBootstrap {
4344
const DEFAULT: bool = true;
4445

4546
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
47+
// This step is responsible for several different tool paths. By default
48+
// it will test all of them, but requesting specific tools on the
49+
// command-line (e.g. `./x test suggest-tests`) will test only the
50+
// specified tools.
4651
run.path("src/tools/jsondoclint")
4752
.path("src/tools/suggest-tests")
4853
.path("src/tools/replace-version-placeholder")
54+
// We want `./x test tidy` to _run_ the tidy tool, not its tests.
55+
// So we need a separate alias to test the tidy tool itself.
4956
.alias("tidyselftest")
5057
}
5158

5259
fn make_run(run: RunConfig<'_>) {
60+
// Create and ensure a separate instance of this step for each path
61+
// that was selected on the command-line (or selected by default).
5362
for path in run.paths {
5463
let path = path.assert_single_path().path.clone();
5564
run.builder.ensure(CrateBootstrap { host: run.target, path });
@@ -60,6 +69,8 @@ impl Step for CrateBootstrap {
6069
let bootstrap_host = builder.config.build;
6170
let compiler = builder.compiler(0, bootstrap_host);
6271
let mut path = self.path.to_str().unwrap();
72+
73+
// Map alias `tidyselftest` back to the actual crate path of tidy.
6374
if path == "tidyselftest" {
6475
path = "src/tools/tidy";
6576
}
@@ -212,6 +223,9 @@ impl Step for HtmlCheck {
212223
}
213224
}
214225

226+
/// Builds cargo and then runs the `src/tools/cargotest` tool, which checks out
227+
/// some representative crate repositories and runs `cargo test` on them, in
228+
/// order to test cargo.
215229
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
216230
pub struct Cargotest {
217231
stage: u32,
@@ -257,6 +271,7 @@ impl Step for Cargotest {
257271
}
258272
}
259273

274+
/// Runs `cargo test` for cargo itself.
260275
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
261276
pub struct Cargo {
262277
stage: u32,
@@ -385,6 +400,7 @@ impl Step for RustAnalyzer {
385400
}
386401
}
387402

403+
/// Runs `cargo test` for rustfmt.
388404
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
389405
pub struct Rustfmt {
390406
stage: u32,
@@ -589,6 +605,8 @@ impl Step for Miri {
589605
}
590606
}
591607

608+
/// Runs `cargo miri test` to demonstrate that `src/tools/miri/cargo-miri`
609+
/// works and that libtest works under miri.
592610
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
593611
pub struct CargoMiri {
594612
target: TargetSelection,
@@ -1020,6 +1038,10 @@ impl Step for RustdocGUI {
10201038
}
10211039
}
10221040

1041+
/// Runs `src/tools/tidy` and `cargo fmt --check` to detect various style
1042+
/// problems in the repository.
1043+
///
1044+
/// (To run the tidy tool's internal tests, use the alias "tidyselftest" instead.)
10231045
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
10241046
pub struct Tidy;
10251047

@@ -1230,6 +1252,8 @@ impl Step for RunMakeSupport {
12301252
}
12311253
}
12321254

1255+
/// Runs `cargo test` on the `src/tools/run-make-support` crate.
1256+
/// That crate is used by run-make tests.
12331257
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12341258
pub struct CrateRunMakeSupport {
12351259
host: TargetSelection,
@@ -2466,6 +2490,10 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
24662490
}
24672491
}
24682492

2493+
/// Runs `cargo test` for the compiler crates in `compiler/`.
2494+
///
2495+
/// (This step does not test `rustc_codegen_cranelift` or `rustc_codegen_gcc`,
2496+
/// which have their own separate test steps.)
24692497
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24702498
pub struct CrateLibrustc {
24712499
compiler: Compiler,
@@ -2494,6 +2522,7 @@ impl Step for CrateLibrustc {
24942522
fn run(self, builder: &Builder<'_>) {
24952523
builder.ensure(compile::Std::new(self.compiler, self.target));
24962524

2525+
// To actually run the tests, delegate to a copy of the `Crate` step.
24972526
builder.ensure(Crate {
24982527
compiler: self.compiler,
24992528
target: self.target,
@@ -2619,6 +2648,13 @@ fn prepare_cargo_test(
26192648
cargo
26202649
}
26212650

2651+
/// Runs `cargo test` for standard library crates.
2652+
///
2653+
/// (Also used internally to run `cargo test` for compiler crates.)
2654+
///
2655+
/// FIXME(Zalathar): Try to split this into two separate steps: a user-visible
2656+
/// step for testing standard library crates, and an internal step used for both
2657+
/// library crates and compiler crates.
26222658
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
26232659
pub struct Crate {
26242660
pub compiler: Compiler,
@@ -3552,6 +3588,10 @@ impl Step for CodegenGCC {
35523588
}
35533589
}
35543590

3591+
/// Test step that does two things:
3592+
/// - Runs `cargo test` for the `src/etc/test-float-parse` tool.
3593+
/// - Invokes the `test-float-parse` tool to test the standard library's
3594+
/// float parsing routines.
35553595
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
35563596
pub struct TestFloatParse {
35573597
path: PathBuf,
@@ -3625,6 +3665,9 @@ impl Step for TestFloatParse {
36253665
}
36263666
}
36273667

3668+
/// Runs the tool `src/tools/collect-license-metadata` in `ONLY_CHECK=1` mode,
3669+
/// which verifies that `license-metadata.json` is up-to-date and therefore
3670+
/// running the tool normally would not update anything.
36283671
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
36293672
pub struct CollectLicenseMetadata;
36303673

0 commit comments

Comments
 (0)