diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-04 21:54:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-04 21:54:57 +0200 |
| commit | cfc2297cfc8b8cf105c55442af8164aa759aa568 (patch) | |
| tree | 187a18ee0e1ed169d407c902e1d21e03486a472a /src/librustdoc | |
| parent | 00f608af18098e35135d79e907565c8d310dbce1 (diff) | |
| parent | f9927ee042f7d7418fbb64082272ce1feff4d895 (diff) | |
| download | rust-cfc2297cfc8b8cf105c55442af8164aa759aa568.tar.gz rust-cfc2297cfc8b8cf105c55442af8164aa759aa568.zip | |
Rollup merge of #139328 - GuillaumeGomez:fix-panic-output-137970, r=fmease
Fix 2024 edition doctest panic output Fixes #137970. The problem was that the output was actually displayed by rustc itself because we're exiting with `Result<(), String>`, and the display is really not great. So instead, we get the output, we print it and then we return an `ExitCode`. r? ````@aDotInTheVoid````
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/doctest/runner.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustdoc/doctest/runner.rs b/src/librustdoc/doctest/runner.rs index e34b8a53b07..784d628805d 100644 --- a/src/librustdoc/doctest/runner.rs +++ b/src/librustdoc/doctest/runner.rs @@ -113,6 +113,7 @@ impl DocTestRunner { mod __doctest_mod {{ use std::sync::OnceLock; use std::path::PathBuf; + use std::process::ExitCode; pub static BINARY_PATH: OnceLock<PathBuf> = OnceLock::new(); pub const RUN_OPTION: &str = \"RUSTDOC_DOCTEST_RUN_NB_TEST\"; @@ -123,16 +124,17 @@ mod __doctest_mod {{ }} #[allow(unused)] - pub fn doctest_runner(bin: &std::path::Path, test_nb: usize) -> Result<(), String> {{ + pub fn doctest_runner(bin: &std::path::Path, test_nb: usize) -> ExitCode {{ let out = std::process::Command::new(bin) .env(self::RUN_OPTION, test_nb.to_string()) .args(std::env::args().skip(1).collect::<Vec<_>>()) .output() .expect(\"failed to run command\"); if !out.status.success() {{ - Err(String::from_utf8_lossy(&out.stderr).to_string()) + eprint!(\"{{}}\", String::from_utf8_lossy(&out.stderr)); + ExitCode::FAILURE }} else {{ - Ok(()) + ExitCode::SUCCESS }} }} }} |
