fix(test): guarantee manual-test sandbox cleanup via Drop#413
Merged
Conversation
The per-scenario `test_env.cleanup()` call only ran on the Ok-return path, so any `?` propagation during repo generation, template creation, or step execution would leak the `/tmp/daft-manual-test-<ts>/` sandbox. Add an RAII `Drop` impl on `TestEnv` that removes `base_dir` unless `--keep` or `--setup-only` was requested. The `cleanup_on_drop` flag is set inside `create()` so the guarantee covers every error path between construction and the explicit cleanup call. The explicit `cleanup()` (with its UX message) and the SIGINT handler remain — the SIGINT handler calls `process::exit` which skips destructors, mirroring how `RawModeGuard` in interactive.rs coexists with explicit terminal-state restoration.
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.
Summary
/tmp/daft-manual-test-<ts>/sandboxes — 600+ orphans accumulated locally over a single day of testing.TestEnv::cleanup()call inmod.rs:169only ran on the Ok-return path, so any?propagation during repo generation, template creation, or step execution skipped cleanup. The SIGINT handler covered Ctrl+C but not panics or other errors.Dropimpl onTestEnvthat removesbase_dirunless--keepor--setup-onlywas requested. Thecleanup_on_dropflag is set insidecreate()itself so the guarantee covers every error path between construction and the explicit cleanup call.RawModeGuardDrop ininteractive.rs:32. The explicitcleanup()(with its UX message) and SIGINT handler both stay —process::exitin the SIGINT handler skips destructors, so explicit cleanup there is still load-bearing.Test plan
cargo build -p xtask— clean, no warningsmise run clippy— zero warningscargo test -p xtask— 53/53 tests passmise run test:unit— pass