Skip to content

fix(test): guarantee manual-test sandbox cleanup via Drop#413

Merged
avihut merged 1 commit into
masterfrom
fix/manual-test-env-cleanup
Apr 26, 2026
Merged

fix(test): guarantee manual-test sandbox cleanup via Drop#413
avihut merged 1 commit into
masterfrom
fix/manual-test-env-cleanup

Conversation

@avihut
Copy link
Copy Markdown
Owner

@avihut avihut commented Apr 26, 2026

Summary

  • Manual-test runs were leaking /tmp/daft-manual-test-<ts>/ sandboxes — 600+ orphans accumulated locally over a single day of testing.
  • The existing TestEnv::cleanup() call in mod.rs:169 only 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.
  • Adds 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() itself so the guarantee covers every error path between construction and the explicit cleanup call.
  • Pattern mirrors the existing RawModeGuard Drop in interactive.rs:32. The explicit cleanup() (with its UX message) and SIGINT handler both stay — process::exit in the SIGINT handler skips destructors, so explicit cleanup there is still load-bearing.

Test plan

  • cargo build -p xtask — clean, no warnings
  • mise run clippy — zero warnings
  • cargo test -p xtask — 53/53 tests pass
  • mise run test:unit — pass
  • Verify locally that a forced-error scenario no longer leaks a sandbox dir

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.
@avihut avihut added this to the Public Launch milestone Apr 26, 2026
@avihut avihut added the fix Bug fix label Apr 26, 2026
@avihut avihut self-assigned this Apr 26, 2026
@avihut avihut merged commit 4db7161 into master Apr 26, 2026
8 checks passed
@avihut avihut deleted the fix/manual-test-env-cleanup branch April 26, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant