Skip to content

Commit 4dfa59d

Browse files
committed
Add snapshot tests for checking compiler, library and rustc tools
1 parent 3c391a6 commit 4dfa59d

File tree

3 files changed

+182
-1
lines changed

3 files changed

+182
-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};
@@ -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)]
@@ -467,6 +475,10 @@ macro_rules! tool_check_step {
467475
let Self { target } = self;
468476
run_tool_check_step(builder, target, stringify!($name), $path);
469477
}
478+
479+
fn metadata(&self) -> Option<StepMetadata> {
480+
Some(StepMetadata::check(stringify!($name), self.target))
481+
}
470482
}
471483
}
472484
}

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

Lines changed: 4 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
}

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

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

0 commit comments

Comments
 (0)