Skip to content

Delete test folders after each test - #15

Merged
monorkin merged 1 commit into
mainfrom
test-tempdirs
Nov 25, 2026
Merged

monorkin merged 1 commit into
mainfrom
test-tempdirs

Conversation

@monorkin

Copy link
Copy Markdown
Collaborator

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 in plan.rs and tui/files.rs use the same thing from a test-only scratch module.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:33
@monorkin
monorkin merged commit bd86a8a into main Nov 25, 2026
7 checks passed
@monorkin
monorkin deleted the test-tempdirs branch November 25, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 scratch module.
  • 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 run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants