From 59a9e0986d061d095c813db1dc418ab55e9e7771 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Jun 2024 18:03:40 +0200 Subject: [PATCH] Correctly handle the case where there is no doctests to run --- src/librustdoc/doctest.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 818ee16a4acf..5586a23595de 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -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); }