Skip to content

Commit c454ba9

Browse files
committed
Avoid building rustdoc for tests without doctests
1 parent 267c405 commit c454ba9

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
@@ -918,7 +918,10 @@ impl Builder<'_> {
918918
}
919919

920920
let rustdoc_path = match cmd_kind {
921-
Kind::Doc | Kind::Test | Kind::MiriTest => self.rustdoc_for_compiler(compiler),
921+
Kind::Doc => self.rustdoc_for_compiler(compiler),
922+
Kind::Test | Kind::MiriTest if self.test_target.runs_doctests() => {
923+
self.rustdoc_for_compiler(compiler)
924+
}
922925
_ => PathBuf::from("/path/to/nowhere/rustdoc/not/required"),
923926
};
924927

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+
2431+
let steps = ctx.config("test").args(&["--tests", "library/core"]).get_steps();
2432+
2433+
steps.assert_contains_fuzzy(StepMetadata::build("std", host));
2434+
steps.assert_no_match(|metadata| {
2435+
metadata.name == "rustdoc" && metadata.kind == Kind::Build && metadata.target == host
2436+
});
2437+
}
2438+
24262439
#[test]
24272440
fn test_cargo_stage_1() {
24282441
let ctx = TestCtx::new();

0 commit comments

Comments
 (0)