Skip to content

Commit 91dfcfa

Browse files
committed
Add snapshot tests for checking compiler, library and rustc tools
1 parent 8003a1f commit 91dfcfa

File tree

3 files changed

+175
-1
lines changed

3 files changed

+175
-1
lines changed

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

Lines changed: 13 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};
@@ -126,6 +126,10 @@ impl Step for Std {
126126
let _guard = builder.msg_check("library test/bench/example targets", target, Some(stage));
127127
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
128128
}
129+
130+
fn metadata(&self) -> Option<StepMetadata> {
131+
Some(StepMetadata::check("std", self.target).built_by(self.build_compiler))
132+
}
129133
}
130134

131135
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -217,6 +221,10 @@ impl Step for Rustc {
217221
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
218222
add_to_sysroot(builder, &libdir, &hostdir, &stamp);
219223
}
224+
225+
fn metadata(&self) -> Option<StepMetadata> {
226+
Some(StepMetadata::check("rustc", self.target).built_by(self.build_compiler))
227+
}
220228
}
221229

222230
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -426,6 +434,10 @@ macro_rules! tool_check_step {
426434
let Self { target } = self;
427435
run_tool_check_step(builder, target, stringify!($name), $path);
428436
}
437+
438+
fn metadata(&self) -> Option<StepMetadata> {
439+
Some(StepMetadata::check(stringify!($name), self.target))
440+
}
429441
}
430442
}
431443
}

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

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

157+
pub fn check(name: &'static str, target: TargetSelection) -> Self {
158+
Self::new(name, target, Kind::Check)
159+
}
160+
157161
pub fn doc(name: &'static str, target: TargetSelection) -> Self {
158162
Self::new(name, target, Kind::Doc)
159163
}

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

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,164 @@ mod snapshot {
12331233
");
12341234
}
12351235

1236+
#[test]
1237+
fn check_compiler_no_explicit_stage() {
1238+
let ctx = TestCtx::new();
1239+
insta::assert_snapshot!(
1240+
ctx.config("check")
1241+
.path("compiler")
1242+
.render_steps(), @r"
1243+
[build] llvm <host>
1244+
[check] rustc 0 <host> -> rustc 1 <host>
1245+
");
1246+
1247+
insta::assert_snapshot!(
1248+
ctx.config("check")
1249+
.path("rustc")
1250+
.render_steps(), @r"
1251+
[build] llvm <host>
1252+
[check] rustc 0 <host> -> rustc 1 <host>
1253+
");
1254+
}
1255+
1256+
#[test]
1257+
#[should_panic]
1258+
fn check_compiler_stage_0() {
1259+
let ctx = TestCtx::new();
1260+
ctx.config("check").path("compiler").stage(0).run();
1261+
}
1262+
1263+
#[test]
1264+
fn check_compiler_stage_1() {
1265+
let ctx = TestCtx::new();
1266+
insta::assert_snapshot!(
1267+
ctx.config("check")
1268+
.path("compiler")
1269+
.stage(1)
1270+
.render_steps(), @r"
1271+
[build] llvm <host>
1272+
[check] rustc 0 <host> -> rustc 1 <host>
1273+
");
1274+
}
1275+
1276+
#[test]
1277+
fn check_compiler_stage_2() {
1278+
let ctx = TestCtx::new();
1279+
insta::assert_snapshot!(
1280+
ctx.config("check")
1281+
.path("compiler")
1282+
.stage(2)
1283+
.render_steps(), @r"
1284+
[build] llvm <host>
1285+
[build] rustc 0 <host> -> rustc 1 <host>
1286+
[build] rustc 1 <host> -> std 1 <host>
1287+
[check] rustc 1 <host> -> rustc 2 <host>
1288+
");
1289+
}
1290+
1291+
#[test]
1292+
fn check_library_no_explicit_stage() {
1293+
let ctx = TestCtx::new();
1294+
insta::assert_snapshot!(
1295+
ctx.config("check")
1296+
.path("library")
1297+
.render_steps(), @r"
1298+
[build] llvm <host>
1299+
[build] rustc 0 <host> -> rustc 1 <host>
1300+
[check] rustc 1 <host> -> std 1 <host>
1301+
");
1302+
}
1303+
1304+
#[test]
1305+
#[should_panic]
1306+
fn check_library_stage_0() {
1307+
let ctx = TestCtx::new();
1308+
ctx.config("check").path("library").stage(0).run();
1309+
}
1310+
1311+
#[test]
1312+
fn check_library_stage_1() {
1313+
let ctx = TestCtx::new();
1314+
insta::assert_snapshot!(
1315+
ctx.config("check")
1316+
.path("library")
1317+
.stage(1)
1318+
.render_steps(), @r"
1319+
[build] llvm <host>
1320+
[build] rustc 0 <host> -> rustc 1 <host>
1321+
[check] rustc 1 <host> -> std 1 <host>
1322+
");
1323+
}
1324+
1325+
#[test]
1326+
fn check_library_stage_2() {
1327+
let ctx = TestCtx::new();
1328+
insta::assert_snapshot!(
1329+
ctx.config("check")
1330+
.path("library")
1331+
.stage(2)
1332+
.render_steps(), @r"
1333+
[build] llvm <host>
1334+
[build] rustc 0 <host> -> rustc 1 <host>
1335+
[build] rustc 1 <host> -> std 1 <host>
1336+
[build] rustc 1 <host> -> rustc 2 <host>
1337+
[check] rustc 2 <host> -> std 2 <host>
1338+
");
1339+
}
1340+
1341+
#[test]
1342+
fn check_miri_no_explicit_stage() {
1343+
let ctx = TestCtx::new();
1344+
insta::assert_snapshot!(
1345+
ctx.config("check")
1346+
.path("miri")
1347+
.render_steps(), @r"
1348+
[build] llvm <host>
1349+
[build] rustc 0 <host> -> rustc 1 <host>
1350+
[check] rustc 0 <host> -> rustc 1 <host>
1351+
[check] Miri <host>
1352+
");
1353+
}
1354+
1355+
#[test]
1356+
#[should_panic]
1357+
fn check_miri_stage_0() {
1358+
let ctx = TestCtx::new();
1359+
ctx.config("check").path("miri").stage(0).run();
1360+
}
1361+
1362+
#[test]
1363+
fn check_miri_stage_1() {
1364+
let ctx = TestCtx::new();
1365+
insta::assert_snapshot!(
1366+
ctx.config("check")
1367+
.path("miri")
1368+
.stage(1)
1369+
.render_steps(), @r"
1370+
[build] llvm <host>
1371+
[build] rustc 0 <host> -> rustc 1 <host>
1372+
[check] rustc 0 <host> -> rustc 1 <host>
1373+
[check] Miri <host>
1374+
");
1375+
}
1376+
1377+
#[test]
1378+
fn check_miri_stage_2() {
1379+
let ctx = TestCtx::new();
1380+
insta::assert_snapshot!(
1381+
ctx.config("check")
1382+
.path("miri")
1383+
.stage(2)
1384+
.render_steps(), @r"
1385+
[build] llvm <host>
1386+
[build] rustc 0 <host> -> rustc 1 <host>
1387+
[build] rustc 1 <host> -> std 1 <host>
1388+
[build] rustc 1 <host> -> rustc 2 <host>
1389+
[check] rustc 1 <host> -> rustc 2 <host>
1390+
[check] Miri <host>
1391+
");
1392+
}
1393+
12361394
#[test]
12371395
fn test_exclude() {
12381396
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)