Repository navigation
Delete test folders after each test - #15
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approved
No active review issues require changes before approval.
No open issues 🎉
What changed in this PR
This PR prevents temporary test directories from accumulating by deleting them when their owners go out of scope, while keeping fixtures available for the full duration of each test.
Changes:
- Add automatic directory cleanup to integration-test helpers and a shared, test-only
scratchmodule. - Update checkout and file-picker fixtures to retain directory ownership.
- Preserve directory lifetimes across subprocesses, concurrent commands, and MCP sessions.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
tests/support/mod.rs |
Return temporary-directory owners that clean up on drop. |
tests/sign_ins.rs |
Retain directory owners while sharing paths and running scripts. |
tests/read.rs |
Keep temporary checkout directories alive throughout tests. |
tests/read_only.rs |
Preserve ownership of temporary checkout fixtures. |
tests/mcp.rs |
Retain configuration ownership for the MCP session. |
tests/hostile_server.rs |
Keep the checkout’s temporary parent alive during the test. |
src/tui/files.rs |
Use owned temporary directories for file-picker tests. |
src/scratch.rs |
Add a shared unit-test directory owner with automatic cleanup. |
src/plan.rs |
Wrap checkout fixtures with their backing directory owner. |
src/main.rs |
Register the scratch module only for tests. |
Review effort: Balanced
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.
Tests left a folder in the temp dir for every run, and the plan tests 14–17 per run. They added up to thousands of folders and once filled /tmp.
Test folders are now deleted when the test that made them finishes:
tempdir()in the integration tests returns a folder that's removed when dropped, and the unit tests inplan.rsandtui/files.rsuse the same thing from a test-onlyscratchmodule.