Skip to content

[rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed #140706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

Fixes #139899.

The bug was due to the fact that if any doctest fails for any reason, we call exit (or it's called inside libtest if not edition 2024), meaning that TempDir's destructor isn't called, and therefore the temporary folder isn't cleaned up.

Took me a while to figure out how to reproduce but finally I was able to reproduce the bug with:

#![doc(test(attr(deny(warnings))))]

//! ```
//! let a = 12;
//! ```

And then I ensured that panicking doctests were cleaned up as well:

//! ```
//! panic!();
//! ```

And finally I checked if it was fixed for merged doctests too (--edition 2024).

To make this work, I needed to add a new public function in libtest too which would call a function once all tests have been run.

So only issue is: I have absolutely no idea how we can add a regression test for this fix. If anyone has an idea...

r? @notriddle

…o allow a callback to be called before exiting
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels May 6, 2025
@GuillaumeGomez GuillaumeGomez force-pushed the fix-missing-temp-dir-cleanup branch from 9959875 to 173cdaf Compare May 6, 2025 17:32
@GuillaumeGomez
Copy link
Member Author

Applied suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thousands of /tmp/rustdoctest* directories
3 participants