Skip to content

Add bootstrap check snapshot tests #143316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::core::build_steps::compile::{
};
use crate::core::build_steps::tool::{COMPILETEST_ALLOW_FEATURES, SourceType, prepare_tool_cargo};
use crate::core::builder::{
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, crate_description,
self, Alias, Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description,
};
use crate::core::config::TargetSelection;
use crate::utils::build_stamp::{self, BuildStamp};
Expand Down Expand Up @@ -167,6 +167,10 @@ impl Step for Std {
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("std", self.target))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -258,6 +262,10 @@ impl Step for Rustc {
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
add_to_sysroot(builder, &libdir, &hostdir, &stamp);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check("rustc", self.target))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -467,6 +475,10 @@ macro_rules! tool_check_step {
let Self { target } = self;
run_tool_check_step(builder, target, stringify!($name), $path);
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::check(stringify!($name), self.target))
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ impl StepMetadata {
Self::new(name, target, Kind::Build)
}

pub fn check(name: &'static str, target: TargetSelection) -> Self {
Self::new(name, target, Kind::Check)
}

pub fn doc(name: &'static str, target: TargetSelection) -> Self {
Self::new(name, target, Kind::Doc)
}
Expand Down
165 changes: 165 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,171 @@ mod snapshot {
");
}

#[test]
fn check_compiler_no_explicit_stage() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("compiler")
.render_steps(), @r"
[check] std <host>
[build] llvm <host>
[check] rustc <host>
");

insta::assert_snapshot!(
ctx.config("check")
.path("rustc")
.render_steps(), @r"
[build] llvm <host>
[check] rustc 0 <host> -> rustc 1 <host>
");
}

#[test]
#[should_panic]
fn check_compiler_stage_0() {
let ctx = TestCtx::new();
ctx.config("check").path("compiler").stage(0).run();
}

#[test]
fn check_compiler_stage_1() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("compiler")
.stage(1)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[check] rustc <host>
Comment on lines +1275 to +1277
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: I'm assuming the staging info is intended to be a follow-up (as in the overall PR) right?

As in, I'd expect the derivation chain for this to look like (overly simplified)

$$\prescript{{}}{\text{host}}{\mathrm{LLVM}} \longrightarrow \left\langle \text{compiler}_{\mathrm{0}}^{\mathrm{build}}, \text{library}_{\mathrm{0}}^{\mathrm{build}} \right\rangle \longrightarrow \text{compiler}_{\mathrm{1}}^{\mathrm{check}}$$

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Right now, the check steps implicitly decide which compiler will build them, it's not represented explicitly in their Step parameters. Therefore it's also not easily representable in the step metadata.

");
}

#[test]
fn check_compiler_stage_2() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("compiler")
.stage(2)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[check] rustc <host>
");
}

#[test]
fn check_library_no_explicit_stage() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("library")
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[check] std <host>
");
}

#[test]
#[should_panic]
fn check_library_stage_0() {
let ctx = TestCtx::new();
ctx.config("check").path("library").stage(0).run();
}

#[test]
fn check_library_stage_1() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("library")
.stage(1)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[check] std <host>
");
}

#[test]
fn check_library_stage_2() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("library")
.stage(2)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[check] std <host>
");
}

#[test]
fn check_miri_no_explicit_stage() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("miri")
.render_steps(), @r"
[check] std <host>
[build] llvm <host>
[check] rustc <host>
[check] Miri <host>
");
}

#[test]
#[should_panic]
fn check_miri_stage_0() {
let ctx = TestCtx::new();
ctx.config("check").path("miri").stage(0).run();
}

#[test]
fn check_miri_stage_1() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("miri")
.stage(1)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[check] rustc <host>
[check] Miri <host>
");
}

#[test]
fn check_miri_stage_2() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("check")
.path("miri")
.stage(2)
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> std 2 <host>
[check] rustc <host>
[check] Miri <host>
");
}

#[test]
fn test_exclude() {
let ctx = TestCtx::new();
Expand Down