Skip to content

Commit 4a3c2fc

Browse files
authored
Rollup merge of #143316 - Kobzol:bootstrap-check-tests, r=jieyouxu
Add bootstrap check snapshot tests Split off from #143048, so that we get a baseline of how check behaved before we make changes to it. Note that the output of the check snapshot tests is suboptimal in many places, as we're missing information about stages and the build compiler. That will be changed in #143048. r? `@jieyouxu`
2 parents 547dc74 + 3f3c498 commit 4a3c2fc

File tree

5 files changed

+373
-63
lines changed

5 files changed

+373
-63
lines changed

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::core::build_steps::compile::{
55
};
66
use crate::core::build_steps::tool::{COMPILETEST_ALLOW_FEATURES, SourceType, prepare_tool_cargo};
77
use crate::core::builder::{
8-
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description,
8+
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description,
99
};
1010
use crate::core::config::TargetSelection;
1111
use crate::utils::build_stamp::{self, BuildStamp};
@@ -167,6 +167,10 @@ impl Step for Std {
167167
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
168168
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
169169
}
170+
171+
fn metadata(&self) -> Option<StepMetadata> {
172+
Some(StepMetadata::check("std", self.target))
173+
}
170174
}
171175

172176
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -258,6 +262,10 @@ impl Step for Rustc {
258262
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
259263
add_to_sysroot(builder, &libdir, &hostdir, &stamp);
260264
}
265+
266+
fn metadata(&self) -> Option<StepMetadata> {
267+
Some(StepMetadata::check("rustc", self.target))
268+
}
261269
}
262270

263271
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -315,6 +323,10 @@ impl Step for CodegenBackend {
315323

316324
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
317325
}
326+
327+
fn metadata(&self) -> Option<StepMetadata> {
328+
Some(StepMetadata::check(self.backend, self.target))
329+
}
318330
}
319331

320332
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -373,6 +385,10 @@ impl Step for RustAnalyzer {
373385
let _guard = builder.msg_check("rust-analyzer artifacts", target, None);
374386
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
375387
}
388+
389+
fn metadata(&self) -> Option<StepMetadata> {
390+
Some(StepMetadata::check("rust-analyzer", self.target))
391+
}
376392
}
377393

378394
/// Compiletest is implicitly "checked" when it gets built in order to run tests,
@@ -432,6 +448,10 @@ impl Step for Compiletest {
432448
let _guard = builder.msg_check("compiletest artifacts", self.target, None);
433449
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
434450
}
451+
452+
fn metadata(&self) -> Option<StepMetadata> {
453+
Some(StepMetadata::check("compiletest", self.target))
454+
}
435455
}
436456

437457
macro_rules! tool_check_step {
@@ -467,6 +487,10 @@ macro_rules! tool_check_step {
467487
let Self { target } = self;
468488
run_tool_check_step(builder, target, stringify!($name), $path);
469489
}
490+
491+
fn metadata(&self) -> Option<StepMetadata> {
492+
Some(StepMetadata::check(stringify!($name), self.target))
493+
}
470494
}
471495
}
472496
}

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,7 @@ impl Step for Std {
306306
}
307307

308308
fn metadata(&self) -> Option<StepMetadata> {
309-
Some(
310-
StepMetadata::build("std", self.target)
311-
.built_by(self.compiler)
312-
.stage(self.compiler.stage),
313-
)
309+
Some(StepMetadata::build("std", self.target).built_by(self.compiler))
314310
}
315311
}
316312

@@ -1186,11 +1182,7 @@ impl Step for Rustc {
11861182
}
11871183

11881184
fn metadata(&self) -> Option<StepMetadata> {
1189-
Some(
1190-
StepMetadata::build("rustc", self.target)
1191-
.built_by(self.build_compiler)
1192-
.stage(self.build_compiler.stage + 1),
1193-
)
1185+
Some(StepMetadata::build("rustc", self.target).built_by(self.build_compiler))
11941186
}
11951187
}
11961188

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,6 @@ macro_rules! tool_extended {
11951195
Some(
11961196
StepMetadata::build($tool_name, self.target)
11971197
.built_by(self.compiler.with_stage(self.compiler.stage.saturating_sub(1)))
1198-
.stage(self.compiler.stage)
11991198
)
12001199
}
12011200
}

src/bootstrap/src/core/builder/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ impl StepMetadata {
153153
Self::new(name, target, Kind::Build)
154154
}
155155

156+
pub fn check(name: &'static str, target: TargetSelection) -> Self {
157+
Self::new(name, target, Kind::Check)
158+
}
159+
156160
pub fn doc(name: &'static str, target: TargetSelection) -> Self {
157161
Self::new(name, target, Kind::Doc)
158162
}
@@ -178,6 +182,14 @@ impl StepMetadata {
178182
self.stage = Some(stage);
179183
self
180184
}
185+
186+
pub fn get_stage(&self) -> Option<u32> {
187+
self.stage.or(self
188+
.built_by
189+
// For std, its stage corresponds to the stage of the compiler that builds it.
190+
// For everything else, a stage N things gets built by a stage N-1 compiler.
191+
.map(|compiler| if self.name == "std" { compiler.stage } else { compiler.stage + 1 }))
192+
}
181193
}
182194

183195
pub struct RunConfig<'a> {

0 commit comments

Comments
 (0)