Skip to content

Commit 598387b

Browse files
committed
Add snapshot test for cross-compiled dist without docs
1 parent d327d65 commit 598387b

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
145145
}
146146

147147
/// Metadata that describes an executed step, mostly for testing and tracing.
148-
#[allow(unused)]
149-
#[derive(Debug, PartialEq, Eq)]
148+
#[derive(Clone, Debug, PartialEq, Eq)]
150149
pub struct StepMetadata {
151150
name: String,
152151
kind: Kind,

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

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ mod snapshot {
14931493
/// This also serves as an important regression test for <https://github.com/rust-lang/rust/issues/138123>
14941494
/// and <https://github.com/rust-lang/rust/issues/138004>.
14951495
#[test]
1496-
fn dist_all_cross() {
1496+
fn dist_all_cross_extended() {
14971497
let ctx = TestCtx::new();
14981498
insta::assert_snapshot!(
14991499
ctx
@@ -1571,8 +1571,77 @@ mod snapshot {
15711571
");
15721572
}
15731573

1574-
// Enable dist cranelift tarball by default with `x dist` if cranelift is enabled in
1575-
// `rust.codegen-backends`.
1574+
/// Simulates e.g. the powerpc64 builder, which is fully cross-compiled from x64, but it does
1575+
/// not build docs. Crutically, it shouldn't build host stage 2 rustc.
1576+
#[test]
1577+
fn dist_all_cross_extended_no_docs() {
1578+
let ctx = TestCtx::new();
1579+
let steps = ctx
1580+
.config("dist")
1581+
.hosts(&[TEST_TRIPLE_1])
1582+
.targets(&[TEST_TRIPLE_1])
1583+
.args(&[
1584+
"--set",
1585+
"rust.channel=nightly",
1586+
"--set",
1587+
"build.extended=true",
1588+
"--set",
1589+
"build.docs=false",
1590+
])
1591+
.get_steps();
1592+
1593+
// Make sure that we don't build stage2 host rustc
1594+
// steps.assert_no_match(|m| {
1595+
// m.name == "rustc"
1596+
// && m.built_by.map(|b| b.stage) == Some(1)
1597+
// && *m.target.triple == host_target()
1598+
// });
1599+
1600+
insta::assert_snapshot!(
1601+
steps.render(), @r"
1602+
[dist] mingw <target1>
1603+
[build] llvm <host>
1604+
[build] llvm <target1>
1605+
[build] rustc 0 <host> -> rustc 1 <host>
1606+
[build] rustc 0 <host> -> WasmComponentLd 1 <host>
1607+
[build] rustc 1 <host> -> std 1 <target1>
1608+
[build] rustc 1 <host> -> std 1 <host>
1609+
[build] rustc 1 <host> -> rustc 2 <target1>
1610+
[build] rustc 1 <host> -> WasmComponentLd 2 <target1>
1611+
[build] rustdoc 2 <target1>
1612+
[build] rustc 1 <host> -> rust-analyzer-proc-macro-srv 2 <target1>
1613+
[build] rustc 0 <host> -> GenerateCopyright 1 <host>
1614+
[build] rustc 0 <host> -> RustInstaller 1 <host>
1615+
[dist] rustc <target1>
1616+
[build] rustc 1 <host> -> rustc 2 <host>
1617+
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
1618+
[build] rustc 2 <host> -> std 2 <target1>
1619+
[dist] rustc 2 <host> -> std 2 <target1>
1620+
[dist] rustc 1 <host> -> rustc-dev 2 <target1>
1621+
[dist] rustc 1 <host> -> analysis 2 <target1>
1622+
[dist] src <>
1623+
[build] rustc 1 <host> -> cargo 2 <target1>
1624+
[dist] rustc 1 <host> -> cargo 2 <target1>
1625+
[build] rustc 1 <host> -> rust-analyzer 2 <target1>
1626+
[dist] rustc 1 <host> -> rust-analyzer 2 <target1>
1627+
[build] rustc 1 <host> -> rustfmt 2 <target1>
1628+
[build] rustc 1 <host> -> cargo-fmt 2 <target1>
1629+
[dist] rustc 1 <host> -> rustfmt 2 <target1>
1630+
[build] rustc 1 <host> -> clippy-driver 2 <target1>
1631+
[build] rustc 1 <host> -> cargo-clippy 2 <target1>
1632+
[dist] rustc 1 <host> -> clippy 2 <target1>
1633+
[build] rustc 1 <host> -> miri 2 <target1>
1634+
[build] rustc 1 <host> -> cargo-miri 2 <target1>
1635+
[dist] rustc 1 <host> -> miri 2 <target1>
1636+
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1>
1637+
[dist] rustc 1 <host> -> std 1 <target1>
1638+
[dist] rustc 1 <host> -> extended 2 <target1>
1639+
[dist] reproducible-artifacts <target1>
1640+
");
1641+
}
1642+
1643+
/// Enable dist cranelift tarball by default with `x dist` if cranelift is enabled in
1644+
/// `rust.codegen-backends`.
15761645
#[test]
15771646
fn dist_cranelift_by_default() {
15781647
let ctx = TestCtx::new();
@@ -2426,6 +2495,21 @@ impl ExecutedSteps {
24262495
}
24272496
}
24282497

2498+
/// Make sure that no metadata matches the given `func`.
2499+
#[track_caller]
2500+
fn assert_no_match<F>(&self, func: F)
2501+
where
2502+
F: Fn(StepMetadata) -> bool,
2503+
{
2504+
for metadata in self.steps.iter().filter_map(|s| s.metadata.clone()) {
2505+
if func(metadata.clone()) {
2506+
panic!(
2507+
"Metadata {metadata:?} was found, even though it should have not been present"
2508+
);
2509+
}
2510+
}
2511+
}
2512+
24292513
fn contains(&self, metadata: &StepMetadata) -> bool {
24302514
self.steps
24312515
.iter()

0 commit comments

Comments
 (0)