Leave no temporary directories behind in the test suites #19

Merged
Breadway merged 1 commit from fix/ram-29-test-temp-cleanup into main 2026-10-11 16:40:14 +08:00
Owner

Part of RAM-29 (the card stays open: the shared fixtures it asks for are still to come).

Running the suite left one directory per CLI test, per configuration test, and per daemon state-file test in the temporary directory. Repeated runs had to be cleaned by hand, and a stale socket from an earlier run can be mistaken for a live daemon, so this was a defect rather than untidiness.

What this changes

Each test directory now has an owner that removes it when the test ends:

  • cli_contract.rs: the socket path is a TestSocket that derefs to Path (so every call site is unchanged) and removes its directory on drop.
  • host_config.rs: a TempDir guard, one per test.
  • daemon.rs tests: a TempDir guard, replacing the directory that was only removed at the end of the test, and only on the happy path.

Verification

cargo fmt --all --check clean, cargo clippy --workspace --all-targets -- -D warnings clean, cargo test --workspace 388 passed, 0 failed.

The fix is verified by measuring it rather than by reading it: with /tmp/breadram* cleared first, the whole suite now leaves 0 entries behind, where the CLI suite alone previously left one directory per test per run.

docs/AGENT-HANDOFF.md no longer lists the leak, and says what is still open on RAM-29 instead: the shared replay and integration fixtures do not exist yet, so each suite builds its own.

Part of RAM-29 (the card stays open: the shared fixtures it asks for are still to come). Running the suite left one directory per CLI test, per configuration test, and per daemon state-file test in the temporary directory. Repeated runs had to be cleaned by hand, and a stale socket from an earlier run can be mistaken for a live daemon, so this was a defect rather than untidiness. ## What this changes Each test directory now has an owner that removes it when the test ends: - `cli_contract.rs`: the socket path is a `TestSocket` that derefs to `Path` (so every call site is unchanged) and removes its directory on drop. - `host_config.rs`: a `TempDir` guard, one per test. - `daemon.rs` tests: a `TempDir` guard, replacing the directory that was only removed at the end of the test, and only on the happy path. ## Verification `cargo fmt --all --check` clean, `cargo clippy --workspace --all-targets -- -D warnings` clean, `cargo test --workspace` 388 passed, 0 failed. The fix is verified by measuring it rather than by reading it: with `/tmp/breadram*` cleared first, the whole suite now leaves **0** entries behind, where the CLI suite alone previously left one directory per test per run. `docs/AGENT-HANDOFF.md` no longer lists the leak, and says what is still open on RAM-29 instead: the shared replay and integration fixtures do not exist yet, so each suite builds its own.
Running the suite left one directory per CLI test, per config test, and per
daemon state-file test in the temporary directory, so repeated runs had to be
cleaned by hand and a stale socket from an earlier run could be mistaken for a
live daemon.

Give each test directory an owner that removes it when the test ends. The whole
suite now leaves nothing behind, which is checked by running it and counting.
Breadway deleted branch fix/ram-29-test-temp-cleanup 2026-10-11 16:40:14 +08:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Breadway/breadram!19
No description provided.