Skip to content

Commit 62639c9

Browse files
committed
Port more tests to snapshot tests
1 parent 809f750 commit 62639c9

File tree

7 files changed

+614
-647
lines changed

7 files changed

+614
-647
lines changed

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::core::build_steps::doc::DocumentationFormat;
2323
use crate::core::build_steps::tool::{self, Tool};
2424
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
2525
use crate::core::build_steps::{compile, llvm};
26-
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
26+
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata};
2727
use crate::core::config::TargetSelection;
2828
use crate::utils::build_stamp::{self, BuildStamp};
2929
use crate::utils::channel::{self, Info};
@@ -84,6 +84,10 @@ impl Step for Docs {
8484
tarball.add_file(builder.src.join("src/doc/robots.txt"), dest, FileType::Regular);
8585
Some(tarball.generate())
8686
}
87+
88+
fn metadata(&self) -> Option<StepMetadata> {
89+
Some(StepMetadata::dist("docs", self.host))
90+
}
8791
}
8892

8993
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
@@ -354,6 +358,10 @@ impl Step for Mingw {
354358

355359
Some(tarball.generate())
356360
}
361+
362+
fn metadata(&self) -> Option<StepMetadata> {
363+
Some(StepMetadata::dist("mingw", self.host))
364+
}
357365
}
358366

359367
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
@@ -540,6 +548,10 @@ impl Step for Rustc {
540548
}
541549
}
542550
}
551+
552+
fn metadata(&self) -> Option<StepMetadata> {
553+
Some(StepMetadata::dist("rustc", self.compiler.host))
554+
}
543555
}
544556

545557
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
@@ -723,6 +735,10 @@ impl Step for Std {
723735

724736
Some(tarball.generate())
725737
}
738+
739+
fn metadata(&self) -> Option<StepMetadata> {
740+
Some(StepMetadata::dist("std", self.target).built_by(self.compiler))
741+
}
726742
}
727743

728744
/// Tarball containing the compiler that gets downloaded and used by
@@ -1002,6 +1018,10 @@ impl Step for Src {
10021018

10031019
tarball.generate()
10041020
}
1021+
1022+
fn metadata(&self) -> Option<StepMetadata> {
1023+
Some(StepMetadata::dist("src", TargetSelection::default()))
1024+
}
10051025
}
10061026

10071027
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]

src/bootstrap/src/core/build_steps/doc.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use std::{env, fs, mem};
1414
use crate::core::build_steps::compile;
1515
use crate::core::build_steps::tool::{self, SourceType, Tool, prepare_tool_cargo};
1616
use crate::core::builder::{
17-
self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, crate_description,
17+
self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata,
18+
crate_description,
1819
};
1920
use crate::core::config::{Config, TargetSelection};
2021
use crate::helpers::{submodule_path_of, symlink_dir, t, up_to_date};
@@ -662,6 +663,10 @@ impl Step for Std {
662663
}
663664
}
664665
}
666+
667+
fn metadata(&self) -> Option<StepMetadata> {
668+
Some(StepMetadata::doc("std", self.target).stage(self.stage))
669+
}
665670
}
666671

667672
/// Name of the crates that are visible to consumers of the standard library.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use crate::core::build_steps::tool::{self, COMPILETEST_ALLOW_FEATURES, SourceTyp
1919
use crate::core::build_steps::toolstate::ToolState;
2020
use crate::core::build_steps::{compile, dist, llvm};
2121
use crate::core::builder::{
22-
self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, crate_description,
22+
self, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, StepMetadata,
23+
crate_description,
2324
};
2425
use crate::core::config::TargetSelection;
2526
use crate::core::config::flags::{Subcommand, get_completion};
@@ -1174,6 +1175,10 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
11741175
fn make_run(run: RunConfig<'_>) {
11751176
run.builder.ensure(Tidy);
11761177
}
1178+
1179+
fn metadata(&self) -> Option<StepMetadata> {
1180+
Some(StepMetadata::test("tidy", TargetSelection::default()))
1181+
}
11771182
}
11781183

11791184
fn testdir(builder: &Builder<'_>, host: TargetSelection) -> PathBuf {
@@ -1236,6 +1241,12 @@ macro_rules! test {
12361241
}),
12371242
})
12381243
}
1244+
1245+
fn metadata(&self) -> Option<StepMetadata> {
1246+
Some(
1247+
StepMetadata::test(stringify!($name), self.target)
1248+
)
1249+
}
12391250
}
12401251
};
12411252
}
@@ -2483,6 +2494,10 @@ impl Step for CrateLibrustc {
24832494
crates: self.crates,
24842495
});
24852496
}
2497+
2498+
fn metadata(&self) -> Option<StepMetadata> {
2499+
Some(StepMetadata::test("CrateLibrustc", self.target))
2500+
}
24862501
}
24872502

24882503
/// Given a `cargo test` subcommand, add the appropriate flags and run it.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,16 @@ impl Step for Rustdoc {
786786
ToolBuildResult { tool_path, build_compiler, target_compiler }
787787
}
788788
}
789+
790+
fn metadata(&self) -> Option<StepMetadata> {
791+
Some(
792+
StepMetadata::build("rustdoc", self.compiler.host)
793+
// rustdoc is ToolRustc, so stage N rustdoc is built by stage N-1 rustc
794+
// FIXME: make this stage deduction automatic somehow
795+
// FIXME: log the compiler that actually built ToolRustc steps
796+
.stage(self.compiler.stage.saturating_sub(1)),
797+
)
798+
}
789799
}
790800

791801
#[derive(Debug, Clone, Hash, PartialEq, Eq)]

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
140140

141141
/// Metadata that describes an executed step, mostly for testing and tracing.
142142
#[allow(unused)]
143-
#[derive(Debug)]
143+
#[derive(Debug, PartialEq, Eq)]
144144
pub struct StepMetadata {
145145
name: &'static str,
146146
kind: Kind,
@@ -151,7 +151,23 @@ pub struct StepMetadata {
151151

152152
impl StepMetadata {
153153
pub fn build(name: &'static str, target: TargetSelection) -> Self {
154-
Self { name, kind: Kind::Build, target, built_by: None, stage: None }
154+
Self::new(name, target, Kind::Build)
155+
}
156+
157+
pub fn doc(name: &'static str, target: TargetSelection) -> Self {
158+
Self::new(name, target, Kind::Doc)
159+
}
160+
161+
pub fn dist(name: &'static str, target: TargetSelection) -> Self {
162+
Self::new(name, target, Kind::Dist)
163+
}
164+
165+
pub fn test(name: &'static str, target: TargetSelection) -> Self {
166+
Self::new(name, target, Kind::Test)
167+
}
168+
169+
fn new(name: &'static str, target: TargetSelection, kind: Kind) -> Self {
170+
Self { name, kind, target, built_by: None, stage: None }
155171
}
156172

157173
pub fn built_by(mut self, compiler: Compiler) -> Self {

0 commit comments

Comments
 (0)