Skip to content

test(search-cache): don't leak temp dirs in tests - #243

Open
Segzman wants to merge 1 commit into
cardisoft:masterfrom
Segzman:fix/tests-leak-tempdirs
Open

Segzman wants to merge 1 commit into
cardisoft:masterfrom
Segzman:fix/tests-leak-tempdirs

Conversation

@Segzman

@Segzman Segzman commented Dec 4, 2026

Copy link
Copy Markdown

39 tests across six integration test files created a tempdir::TempDir and then called std::mem::forget, so the directory was never deleted. Every cargo test run left them in $TMPDIR; test_metadata_filter_on_large_set alone writes 1,000 files (~50 MB), and 22 copies (~1.1 GB) had piled up on one machine.

Keep each TempDir alive for the duration of its test instead: remove the forget calls, and have build helpers return the TempDir so callers bind it as _temp_dir. No test logic or assertions changed.

  • cargo test -p search-cache: passes (876 unit tests + 12 integration targets)
  • cargo fmt --check and cargo clippy -p search-cache --tests: clean
  • Zero temp dirs left after a full run (checked with an isolated TMPDIR)

39 tests across six integration test files created a tempdir::TempDir and
then called std::mem::forget, so the directory was never deleted. Every
cargo test run left them in $TMPDIR; test_metadata_filter_on_large_set
alone writes 1000 files (~50 MB), and 22 copies (~1.1 GB) had piled up on
one machine.

Keep each TempDir alive for the duration of its test instead: remove the
forget calls, and have build helpers return the TempDir so callers bind
it as _temp_dir. No test logic or assertions changed.
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.

1 participant