Correctly handle the case where there is no doctests to run

This commit is contained in:
Guillaume Gomez 2024-06-10 18:03:40 +02:00
parent a0ae8ac861
commit 59a9e0986d

View file

@ -270,6 +270,7 @@ pub(crate) fn run_tests(
}
let mut nb_errors = 0;
let mut ran_edition_tests = 0;
let target_str = rustdoc_options.target.to_string();
for (edition, mut doctests) in mergeable_tests {
@ -296,6 +297,7 @@ pub(crate) fn run_tests(
&test_args,
rustdoc_options,
) {
ran_edition_tests += 1;
if !success {
nb_errors += 1;
}
@ -322,7 +324,9 @@ pub(crate) fn run_tests(
}
}
if !standalone_tests.is_empty() {
// We need to call `test_main` even if there is no doctest to run to get the output
// `running 0 tests...`.
if ran_edition_tests == 0 || !standalone_tests.is_empty() {
standalone_tests.sort_by(|a, b| a.desc.name.as_slice().cmp(&b.desc.name.as_slice()));
test::test_main(&test_args, standalone_tests, None);
}