Skip to content

Commit 912d8f2

Browse files
Rollup merge of #158561 - chenyukang:yukang-fix-158299-core-tests-rustdoc, r=Kobzol
Avoid building rustdoc for tests without doctests Fixes #158299
2 parents 3dc45e1 + 69f0187 commit 912d8f2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,10 @@ impl Builder<'_> {
933933
}
934934

935935
let rustdoc_path = match cmd_kind {
936-
Kind::Doc | Kind::Test | Kind::MiriTest => self.rustdoc_for_compiler(compiler),
936+
Kind::Doc => self.rustdoc_for_compiler(compiler),
937+
Kind::Test | Kind::MiriTest if self.test_target.runs_doctests() => {
938+
self.rustdoc_for_compiler(compiler)
939+
}
937940
_ => PathBuf::from("/path/to/nowhere/rustdoc/not/required"),
938941
};
939942

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,19 @@ mod snapshot {
24232423
}
24242424
}
24252425

2426+
#[test]
2427+
fn test_library_tests_only_does_not_build_rustdoc() {
2428+
let ctx = TestCtx::new();
2429+
let host = TargetSelection::from_user(&host_target());
2430+
insta::assert_snapshot!(
2431+
ctx.config("test").args(&["--tests", "library/core"]).render_steps(),
2432+
@r"
2433+
[build] llvm <host>
2434+
[build] rustc 0 <host> -> rustc 1 <host>
2435+
[build] rustc 1 <host> -> std 1 <host>
2436+
");
2437+
}
2438+
24262439
#[test]
24272440
fn test_cargo_stage_1() {
24282441
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)