Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 59a9e09

Browse files
Correctly handle the case where there is no doctests to run
1 parent a0ae8ac commit 59a9e09

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustdoc/doctest.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ pub(crate) fn run_tests(
270270
}
271271

272272
let mut nb_errors = 0;
273+
let mut ran_edition_tests = 0;
273274
let target_str = rustdoc_options.target.to_string();
274275

275276
for (edition, mut doctests) in mergeable_tests {
@@ -296,6 +297,7 @@ pub(crate) fn run_tests(
296297
&test_args,
297298
rustdoc_options,
298299
) {
300+
ran_edition_tests += 1;
299301
if !success {
300302
nb_errors += 1;
301303
}
@@ -322,7 +324,9 @@ pub(crate) fn run_tests(
322324
}
323325
}
324326

325-
if !standalone_tests.is_empty() {
327+
// We need to call `test_main` even if there is no doctest to run to get the output
328+
// `running 0 tests...`.
329+
if ran_edition_tests == 0 || !standalone_tests.is_empty() {
326330
standalone_tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
327331
test::test_main(&test_args, standalone_tests, None);
328332
}

0 commit comments

Comments
 (0)