Repository navigation
test: keep TMPDIR outside the directory a test deletes - #12
Merged
Merged
Conversation
build_proot_args_non_isolated_includes_prefix_and_mounts pointed TMPDIR at <its temp dir>/cache and then removed that temp dir. The other tests build their scratch paths with std::env::temp_dir(), which reads TMPDIR, and 25 of them do not take the env lock. One that ran in that window created its files inside the doomed tree and lost them: read_helpers_report_expected_access failed with `assertion failed: can_read_file(...)` on main's CI after #11, and in 1 of 40 local runs. Both tests that set TMPDIR now set it to the value temp_dir() already returns, so they still check that TMPDIR wins over the $APP_PREFIX/tmp fallback while no other test sees a different temp dir (build_proot_runtime_env_prefers_tmpdir_when_set used /tmp/custom-cache, where tests running in its window left directories), and they restore the caller's TMPDIR instead of removing it. 0 failures in 240 local runs with TMPDIR unset and 60 with it set.
oonid
force-pushed
the
fix/test-tmpdir-race
branch
from
October 17, 2026 12:30
f853b11 to
cc0c7c3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
main's CI failed after #11 in a test unrelated to it:
shared::tests::read_helpers_report_expected_access(assertion failed: can_read_file(...)).Cause.
build_proot_args_non_isolated_includes_prefix_and_mountssetTMPDIRto<its temp dir>/cacheand then removed that temp dir. Tests build scratch paths withstd::env::temp_dir(), which readsTMPDIR, and 25 of them do not take the env lock. One that ran in that window created its files inside the doomed tree and lost them. Reproduced locally in 1 of 40cargo test --libruns on main.Fix. Both tests that set
TMPDIRnow set it to the valuetemp_dir()already returns, so they still check thatTMPDIRwins over the$APP_PREFIX/tmpfallback while no other test sees a different temp dir, and they restore the caller'sTMPDIRinstead of removing it. (build_proot_runtime_env_prefers_tmpdir_when_setused/tmp/custom-cache; tests running in its window created directories there.)Same class, checked. Of the other env vars tests set,
APP_PREFIXis set by 27 tests; the 15 unlocked tests that reach env-reading code only assert values that do not depend on it (early validation errors, paths from/proc/self/exe, the fixed DNS fallback,LANG), soTMPDIRwas the only path to this failure.Verification. 0 failures in 240 local
cargo test --libruns withTMPDIRunset and 60 with it set to a custom dir;cargo test169 passed; fmt clean, clippy unchanged (21 pre-existing). Re-running main's failed job passed, as expected for a race.