From 227abb70ab2e3d10f05fe933d3c77ecbb04eb9a9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 22 Jul 2025 12:03:15 +0200 Subject: [PATCH 1/2] Make `libtest::ERROR_EXIT_CODE` const public to not redefine it in rustdoc --- library/test/src/lib.rs | 4 ++-- src/librustdoc/doctest.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 7f56d1e362698..1190bb56b97a0 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -89,8 +89,8 @@ use options::RunStrategy; use test_result::*; use time::TestExecTime; -// Process exit code to be used to indicate test failures. -const ERROR_EXIT_CODE: i32 = 101; +/// Process exit code to be used to indicate test failures. +pub const ERROR_EXIT_CODE: i32 = 101; const SECONDARY_TEST_INVOKER_VAR: &str = "__RUST_TEST_INVOKE"; const SECONDARY_TEST_BENCH_BENCHMARKS_VAR: &str = "__RUST_TEST_BENCH_BENCHMARKS"; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 0bef091468f2b..a4344c87e028d 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -410,7 +410,7 @@ pub(crate) fn run_tests( std::mem::drop(temp_dir); times.display_times(); // libtest::ERROR_EXIT_CODE is not public but it's the same value. - std::process::exit(101); + std::process::exit(test::ERROR_EXIT_CODE); } } From bee5fbf36e9cbb7f3317ce6a71b3574dc007dee5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 22 Jul 2025 13:31:12 +0200 Subject: [PATCH 2/2] Fix CI build failure when using new libtest public constant --- src/librustdoc/doctest.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index a4344c87e028d..35ace6566381b 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -409,8 +409,9 @@ pub(crate) fn run_tests( // We ensure temp dir destructor is called. std::mem::drop(temp_dir); times.display_times(); - // libtest::ERROR_EXIT_CODE is not public but it's the same value. - std::process::exit(test::ERROR_EXIT_CODE); + // FIXME(GuillaumeGomez): Uncomment the next line once #144297 has been merged. + // std::process::exit(test::ERROR_EXIT_CODE); + std::process::exit(101); } }