Skip to content

Commit a3d8ae7

Browse files
committed
Add metadata to a bunch of steps, rename variables and add comments
1 parent b6c46d4 commit a3d8ae7

File tree

2 files changed

+102
-28
lines changed

2 files changed

+102
-28
lines changed

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

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ impl Step for CrateBootstrap {
9898
let crate_name = path.rsplit_once('/').unwrap().1;
9999
run_cargo_test(cargo, &[], &[], crate_name, bootstrap_host, builder);
100100
}
101+
102+
fn metadata(&self) -> Option<StepMetadata> {
103+
Some(
104+
StepMetadata::test("crate-bootstrap", self.host)
105+
.with_metadata(self.path.as_path().to_string_lossy().to_string()),
106+
)
107+
}
101108
}
102109

103110
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -173,6 +180,10 @@ You can skip linkcheck with --skip src/tools/linkchecker"
173180
fn make_run(run: RunConfig<'_>) {
174181
run.builder.ensure(Linkcheck { host: run.target });
175182
}
183+
184+
fn metadata(&self) -> Option<StepMetadata> {
185+
Some(StepMetadata::test("link-check", self.host))
186+
}
176187
}
177188

178189
fn check_if_tidy_is_installed(builder: &Builder<'_>) -> bool {
@@ -221,6 +232,10 @@ impl Step for HtmlCheck {
221232
.arg(builder.doc_out(self.target))
222233
.run(builder);
223234
}
235+
236+
fn metadata(&self) -> Option<StepMetadata> {
237+
Some(StepMetadata::test("html-check", self.target))
238+
}
224239
}
225240

226241
/// Builds cargo and then runs the `src/tools/cargotest` tool, which checks out
@@ -399,6 +414,10 @@ impl Step for Cargo {
399414
let _time = helpers::timeit(builder);
400415
add_flags_and_try_run_tests(builder, &mut cargo);
401416
}
417+
418+
fn metadata(&self) -> Option<StepMetadata> {
419+
Some(StepMetadata::test("cargo", self.host).built_by(self.build_compiler))
420+
}
402421
}
403422

404423
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -457,6 +476,13 @@ impl Step for RustAnalyzer {
457476
cargo.add_rustc_lib_path(builder);
458477
run_cargo_test(cargo, &[], &[], "rust-analyzer", host, builder);
459478
}
479+
480+
fn metadata(&self) -> Option<StepMetadata> {
481+
Some(
482+
StepMetadata::test("rust-analyzer", self.compilers.target())
483+
.built_by(self.compilers.build_compiler()),
484+
)
485+
}
460486
}
461487

462488
/// Runs `cargo test` for rustfmt.
@@ -508,6 +534,13 @@ impl Step for Rustfmt {
508534

509535
run_cargo_test(cargo, &[], &[], "rustfmt", target, builder);
510536
}
537+
538+
fn metadata(&self) -> Option<StepMetadata> {
539+
Some(
540+
StepMetadata::test("rustfmt", self.compilers.target())
541+
.built_by(self.compilers.build_compiler()),
542+
)
543+
}
511544
}
512545

513546
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -887,6 +920,13 @@ impl Step for Clippy {
887920
crate::exit!(1);
888921
}
889922
}
923+
924+
fn metadata(&self) -> Option<StepMetadata> {
925+
Some(
926+
StepMetadata::test("clippy", self.compilers.target())
927+
.built_by(self.compilers.build_compiler()),
928+
)
929+
}
890930
}
891931

892932
fn bin_path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
@@ -895,9 +935,11 @@ fn bin_path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
895935
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
896936
}
897937

938+
/// Run the rustdoc-themes tool to test a given compiler.
898939
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
899940
pub struct RustdocTheme {
900-
pub compiler: Compiler,
941+
/// The compiler (more accurately, its rustdoc) that we test.
942+
test_compiler: Compiler,
901943
}
902944

903945
impl Step for RustdocTheme {
@@ -910,31 +952,44 @@ impl Step for RustdocTheme {
910952
}
911953

912954
fn make_run(run: RunConfig<'_>) {
913-
let compiler = run.builder.compiler(run.builder.top_stage, run.target);
955+
let test_compiler = run.builder.compiler(run.builder.top_stage, run.target);
914956

915-
run.builder.ensure(RustdocTheme { compiler });
957+
run.builder.ensure(RustdocTheme { test_compiler });
916958
}
917959

918960
fn run(self, builder: &Builder<'_>) {
919961
let rustdoc = builder.bootstrap_out.join("rustdoc");
920962
let mut cmd = builder.tool_cmd(Tool::RustdocTheme);
921963
cmd.arg(rustdoc.to_str().unwrap())
922964
.arg(builder.src.join("src/librustdoc/html/static/css/rustdoc.css").to_str().unwrap())
923-
.env("RUSTC_STAGE", self.compiler.stage.to_string())
924-
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
925-
.env("RUSTDOC_LIBDIR", builder.sysroot_target_libdir(self.compiler, self.compiler.host))
965+
.env("RUSTC_STAGE", self.test_compiler.stage.to_string())
966+
.env("RUSTC_SYSROOT", builder.sysroot(self.test_compiler))
967+
.env(
968+
"RUSTDOC_LIBDIR",
969+
builder.sysroot_target_libdir(self.test_compiler, self.test_compiler.host),
970+
)
926971
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
927-
.env("RUSTDOC_REAL", builder.rustdoc_for_compiler(self.compiler))
972+
.env("RUSTDOC_REAL", builder.rustdoc_for_compiler(self.test_compiler))
928973
.env("RUSTC_BOOTSTRAP", "1");
929-
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
974+
cmd.args(linker_args(builder, self.test_compiler.host, LldThreads::No));
930975

931976
cmd.delay_failure().run(builder);
932977
}
978+
979+
fn metadata(&self) -> Option<StepMetadata> {
980+
Some(
981+
StepMetadata::test("rustdoc-theme", self.test_compiler.host)
982+
.stage(self.test_compiler.stage),
983+
)
984+
}
933985
}
934986

987+
/// Test rustdoc JS for the standard library.
935988
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
936989
pub struct RustdocJSStd {
937-
pub target: TargetSelection,
990+
/// Compiler that will build the standary library.
991+
build_compiler: Compiler,
992+
target: TargetSelection,
938993
}
939994

940995
impl Step for RustdocJSStd {
@@ -948,7 +1003,10 @@ impl Step for RustdocJSStd {
9481003
}
9491004

9501005
fn make_run(run: RunConfig<'_>) {
951-
run.builder.ensure(RustdocJSStd { target: run.target });
1006+
run.builder.ensure(RustdocJSStd {
1007+
build_compiler: run.builder.compiler(run.builder.top_stage, run.builder.host_target),
1008+
target: run.target,
1009+
});
9521010
}
9531011

9541012
fn run(self, builder: &Builder<'_>) {
@@ -976,19 +1034,18 @@ impl Step for RustdocJSStd {
9761034
}
9771035
}
9781036
builder.ensure(crate::core::build_steps::doc::Std::from_build_compiler(
979-
builder.compiler(builder.top_stage, builder.host_target),
1037+
self.build_compiler,
9801038
self.target,
9811039
DocumentationFormat::Html,
9821040
));
983-
let _guard = builder.msg(
984-
Kind::Test,
985-
"rustdoc-js-std",
986-
None,
987-
(builder.config.host_target, builder.top_stage),
988-
self.target,
989-
);
1041+
let _guard =
1042+
builder.msg(Kind::Test, "rustdoc-js-std", None, self.build_compiler, self.target);
9901043
command.run(builder);
9911044
}
1045+
1046+
fn metadata(&self) -> Option<StepMetadata> {
1047+
Some(StepMetadata::test("rustdoc-js-std", self.target).stage(self.build_compiler.stage))
1048+
}
9921049
}
9931050

9941051
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
@@ -1046,10 +1103,12 @@ fn get_browser_ui_test_version(builder: &Builder<'_>, npm: &Path) -> Option<Stri
10461103
.or_else(|| get_browser_ui_test_version_inner(builder, npm, true))
10471104
}
10481105

1106+
/// Run GUI tests on a given rustdoc.
10491107
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
10501108
pub struct RustdocGUI {
1051-
pub target: TargetSelection,
1052-
pub compiler: Compiler,
1109+
/// The compiler whose rustdoc we are testing.
1110+
test_compiler: Compiler,
1111+
target: TargetSelection,
10531112
}
10541113

10551114
impl Step for RustdocGUI {
@@ -1073,20 +1132,20 @@ impl Step for RustdocGUI {
10731132
}
10741133

10751134
fn make_run(run: RunConfig<'_>) {
1076-
let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1077-
run.builder.ensure(RustdocGUI { target: run.target, compiler });
1135+
let test_compiler = run.builder.compiler(run.builder.top_stage, run.build_triple());
1136+
run.builder.ensure(RustdocGUI { test_compiler, target: run.target });
10781137
}
10791138

10801139
fn run(self, builder: &Builder<'_>) {
1081-
builder.std(self.compiler, self.target);
1140+
builder.std(self.test_compiler, self.target);
10821141

10831142
let mut cmd = builder.tool_cmd(Tool::RustdocGUITest);
10841143

10851144
let out_dir = builder.test_out(self.target).join("rustdoc-gui");
10861145
build_stamp::clear_if_dirty(
10871146
builder,
10881147
&out_dir,
1089-
&builder.rustdoc_for_compiler(self.compiler),
1148+
&builder.rustdoc_for_compiler(self.test_compiler),
10901149
);
10911150

10921151
if let Some(src) = builder.config.src.to_str() {
@@ -1103,10 +1162,10 @@ impl Step for RustdocGUI {
11031162

11041163
cmd.arg("--jobs").arg(builder.jobs().to_string());
11051164

1106-
cmd.env("RUSTDOC", builder.rustdoc_for_compiler(self.compiler))
1107-
.env("RUSTC", builder.rustc(self.compiler));
1165+
cmd.env("RUSTDOC", builder.rustdoc_for_compiler(self.test_compiler))
1166+
.env("RUSTC", builder.rustc(self.test_compiler));
11081167

1109-
add_rustdoc_cargo_linker_args(&mut cmd, builder, self.compiler.host, LldThreads::No);
1168+
add_rustdoc_cargo_linker_args(&mut cmd, builder, self.test_compiler.host, LldThreads::No);
11101169

11111170
for path in &builder.paths {
11121171
if let Some(p) = helpers::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) {
@@ -1133,9 +1192,13 @@ impl Step for RustdocGUI {
11331192
}
11341193

11351194
let _time = helpers::timeit(builder);
1136-
let _guard = builder.msg(Kind::Test, "rustdoc-gui", None, self.compiler, self.target);
1195+
let _guard = builder.msg_test("rustdoc-gui", (self.target, self.test_compiler.stage));
11371196
try_run_tests(builder, &mut cmd, true);
11381197
}
1198+
1199+
fn metadata(&self) -> Option<StepMetadata> {
1200+
Some(StepMetadata::test("rustdoc-gui", self.target).stage(self.test_compiler.stage))
1201+
}
11391202
}
11401203

11411204
/// Runs `src/tools/tidy` and `cargo fmt --check` to detect various style

src/bootstrap/src/core/builder/tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,6 +1881,10 @@ mod snapshot {
18811881
[test] CrateLibrustc <host>
18821882
[build] rustc 1 <host> -> rustc 2 <host>
18831883
[build] rustdoc 0 <host>
1884+
[test] crate-bootstrap <host> src/tools/coverage-dump
1885+
[test] crate-bootstrap <host> src/tools/jsondoclint
1886+
[test] crate-bootstrap <host> src/tools/replace-version-placeholder
1887+
[test] crate-bootstrap <host> tidyselftest
18841888
[build] rustc 0 <host> -> UnstableBookGen 1 <host>
18851889
[build] rustc 0 <host> -> Rustbook 1 <host>
18861890
[doc] unstable-book (book) <host>
@@ -1905,17 +1909,22 @@ mod snapshot {
19051909
[doc] style-guide (book) <host>
19061910
[doc] rustc 0 <host> -> releases 1 <host>
19071911
[build] rustc 0 <host> -> Linkchecker 1 <host>
1912+
[test] link-check <host>
19081913
[test] tier-check <host>
1914+
[test] rustc 0 <host> -> rust-analyzer 1 <host>
19091915
[doc] rustc (book) <host>
19101916
[test] rustc 1 <host> -> lint-docs 2 <host>
19111917
[doc] rustc 1 <host> -> std 1 <host> crates=[]
1918+
[test] rustc 1 <host> -> rustdoc-js-std 2 <host>
19121919
[build] rustc 0 <host> -> RustdocTheme 1 <host>
1920+
[test] rustdoc-theme 1 <host>
19131921
[test] RustdocUi <host>
19141922
[build] rustc 0 <host> -> JsonDocCk 1 <host>
19151923
[build] rustc 0 <host> -> JsonDocLint 1 <host>
19161924
[test] RustdocJson <host>
19171925
[doc] rustc 0 <host> -> rustc 1 <host>
19181926
[build] rustc 0 <host> -> HtmlChecker 1 <host>
1927+
[test] html-check <host>
19191928
[build] rustc 0 <host> -> RunMakeSupport 1 <host>
19201929
[build] rustc 1 <host> -> cargo 2 <host>
19211930
[test] RunMake <host>
@@ -1962,6 +1971,7 @@ mod snapshot {
19621971
[build] rustc 1 <host> -> std 1 <host>
19631972
[build] rustdoc 1 <host>
19641973
[build] rustdoc 0 <host>
1974+
[test] rustc 0 <host> -> cargo 1 <host>
19651975
");
19661976
}
19671977

@@ -1981,6 +1991,7 @@ mod snapshot {
19811991
[build] rustc 2 <host> -> std 2 <host>
19821992
[build] rustdoc 2 <host>
19831993
[build] rustdoc 1 <host>
1994+
[test] rustc 1 <host> -> cargo 2 <host>
19841995
");
19851996
}
19861997

0 commit comments

Comments
 (0)