tests: every test dir is removed when its test ends, pass or panic

Many test helpers removed their temp dir only before the test, or only
on pass, so runs left them behind: 117,000 filled /tmp (RAM here) and
stopped a mutation run. Each now holds a guard that removes the dir on
drop, unwind included; servers started on a test dir hold its guard
until they stop. A full cargo test --workspace leaves 0 dirs (859
before). just sweep-test-tmp stays for runs killed mid-test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-10-17 20:47:44 -06:00
1 parent b292a505b1
commit a833229d87
44 files changed
+952 -163

No files matched your search

+6 -4
View File
@@ -17,10 +17,12 @@ check: sweep-test-tmp
cargo test --workspace
@just sweep-test-tmp
# Test books go in the system temp dir (often RAM). A test cleans up after
# itself, but one killed mid-run (a mutant's timeout, ^C) can't: tens of
# thousands piled up to 23 GB of RAM (2026-10-15). Remove this user's test
# book dirs older than an hour, so a run in progress elsewhere keeps its own.
# Test books go in the system temp dir (often RAM). Every test's dir is
# removed when the test ends, pass or panic (a guard dropped on unwind;
# until 2026-10-17 many were removed only on pass, or never: 117,000 piled
# up). A run killed mid-test (a mutant's timeout, ^C) runs no destructor,
# so this sweep removes this user's test book dirs older than an hour; a
# run in progress elsewhere keeps its own.
sweep-test-tmp:
@find "${TMPDIR:-/tmp}" /tmp -maxdepth 1 -user "$(id -u)" -type d -mmin +60 \( -name 'wb-*' -o -name 'wanderbooks-*' -o -name 'ledger-*' \) -exec rm -rf {} + 2>/dev/null || true