Skip to content

Commit 381da22

Browse files
committed
Add build staging tests for library, miri and a bootstrap tool
1 parent 3078290 commit 381da22

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

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

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ mod staging {
12481248
}
12491249

12501250
#[test]
1251+
#[should_panic]
12511252
fn build_compiler_stage_0() {
12521253
insta::assert_snapshot!(get_steps("compiler", "build", Some(0)), @"");
12531254
}
@@ -1270,6 +1271,97 @@ mod staging {
12701271
");
12711272
}
12721273

1274+
#[test]
1275+
fn build_library_no_stage() {
1276+
insta::assert_snapshot!(get_steps("library", "build", None), @r"
1277+
[build] llvm <target1>
1278+
[build] rustc 0 <target1> -> rustc 1 <target1>
1279+
[build] rustc 1 <target1> -> std 1 <target1>
1280+
");
1281+
}
1282+
1283+
#[test]
1284+
#[should_panic]
1285+
fn build_library_stage_0() {
1286+
insta::assert_snapshot!(get_steps("library", "build", Some(0)), @"");
1287+
}
1288+
1289+
#[test]
1290+
fn build_library_stage_1() {
1291+
insta::assert_snapshot!(get_steps("library", "build", Some(1)), @r"
1292+
[build] llvm <target1>
1293+
[build] rustc 0 <target1> -> rustc 1 <target1>
1294+
[build] rustc 1 <target1> -> std 1 <target1>
1295+
");
1296+
}
1297+
1298+
#[test]
1299+
fn build_library_stage_2() {
1300+
insta::assert_snapshot!(get_steps("library", "build", Some(2)), @r"
1301+
[build] llvm <target1>
1302+
[build] rustc 0 <target1> -> rustc 1 <target1>
1303+
[build] rustc 1 <target1> -> std 1 <target1>
1304+
[build] rustc 1 <target1> -> rustc 2 <target1>
1305+
[build] rustc 2 <target1> -> std 2 <target1>
1306+
");
1307+
}
1308+
1309+
#[test]
1310+
fn build_miri_no_stage() {
1311+
insta::assert_snapshot!(get_steps("miri", "build", None), @r"
1312+
[build] llvm <target1>
1313+
[build] rustc 0 <target1> -> rustc 1 <target1>
1314+
[build] rustc 1 <target1> -> miri 1 <target1>
1315+
");
1316+
}
1317+
1318+
#[test]
1319+
#[should_panic]
1320+
fn build_miri_stage_0() {
1321+
insta::assert_snapshot!(get_steps("miri", "build", Some(0)), @"");
1322+
}
1323+
1324+
#[test]
1325+
fn build_miri_stage_1() {
1326+
insta::assert_snapshot!(get_steps("miri", "build", Some(1)), @r"
1327+
[build] llvm <target1>
1328+
[build] rustc 0 <target1> -> rustc 1 <target1>
1329+
[build] rustc 1 <target1> -> miri 1 <target1>
1330+
");
1331+
}
1332+
1333+
#[test]
1334+
fn build_miri_stage_2() {
1335+
insta::assert_snapshot!(get_steps("miri", "build", Some(2)), @r"
1336+
[build] llvm <target1>
1337+
[build] rustc 0 <target1> -> rustc 1 <target1>
1338+
[build] rustc 1 <target1> -> std 1 <target1>
1339+
[build] rustc 1 <target1> -> rustc 2 <target1>
1340+
[build] rustc 2 <target1> -> miri 2 <target1>
1341+
");
1342+
}
1343+
1344+
#[test]
1345+
fn build_bootstrap_tool_no_stage() {
1346+
insta::assert_snapshot!(get_steps("opt-dist", "build", None), @"[build] rustc 0 <target1> -> opt-dist 0 <target1>");
1347+
}
1348+
1349+
#[test]
1350+
#[should_panic]
1351+
fn build_bootstrap_tool_stage_0() {
1352+
insta::assert_snapshot!(get_steps("opt-dist", "build", Some(0)), @"");
1353+
}
1354+
1355+
#[test]
1356+
fn build_bootstrap_tool_stage_1() {
1357+
insta::assert_snapshot!(get_steps("opt-dist", "build", Some(1)), @"[build] rustc 0 <target1> -> opt-dist 0 <target1>");
1358+
}
1359+
1360+
#[test]
1361+
fn build_bootstrap_tool_stage_2() {
1362+
insta::assert_snapshot!(get_steps("opt-dist", "build", Some(2)), @"[build] rustc 0 <target1> -> opt-dist 0 <target1>");
1363+
}
1364+
12731365
fn get_steps(path: &str, kind: &str, stage: Option<u32>) -> String {
12741366
let mut args = vec![kind, path];
12751367
let stage_str = stage.map(|v| v.to_string()).unwrap_or_default();
@@ -1308,6 +1400,21 @@ fn render_steps(steps: &[(Box<dyn Any>, Box<dyn Any>)]) -> String {
13081400
std.compiler.stage,
13091401
std.target
13101402
))
1403+
} else if let Some((miri, output)) = downcast_step::<tool::Miri>(step, output) {
1404+
Some(format!(
1405+
"[build] {} -> miri {} <{}>",
1406+
render_compiler(miri.compiler),
1407+
miri.compiler.stage,
1408+
miri.target
1409+
))
1410+
} else if let Some((tool, output)) = downcast_step::<tool::OptimizedDist>(step, output)
1411+
{
1412+
Some(format!(
1413+
"[build] {} -> opt-dist {} <{}>",
1414+
render_compiler(tool.compiler),
1415+
tool.compiler.stage,
1416+
tool.target
1417+
))
13111418
} else if let Some((llvm, output)) = downcast_step::<llvm::Llvm>(step, output) {
13121419
Some(format!("[build] llvm <{}>", llvm.target))
13131420
} else {

0 commit comments

Comments
 (0)