Skip to content

test: delete the temporary files the tests create - #191

Open
Blackclaws wants to merge 1 commit into
Apollo3zehn:devfrom
Blackclaws:test/temp-file-cleanup
Open

Blackclaws wants to merge 1 commit into
Apollo3zehn:devfrom
Blackclaws:test/temp-file-cleanup

Conversation

@Blackclaws

Copy link
Copy Markdown
Contributor

A test run leaves 51 files, 88 MB, in the temporary directory per target framework - about 176 MB for a full dotnet test over net8.0 and net10.0. On a machine whose /tmp is a tmpfs that adds up quickly.

Nearly all of them are the fixtures TestUtils.PrepareTestFile writes through the HDF5 C library. Its 159 callers keep reading the file after it returns, often through objects that outlive the test method, so none of them deletes it. The helper now records every path it hands out and deletes them when the test process exits (best effort: a file still held open cannot be deleted on Windows).

The rest are tests that create a file and never remove it - the writing link tests, ThrowsForCircularObjectReference, and the external file of the two external link tests. They now delete it in a finally block, like the other writing tests.

Verification

TMPDIR pointed at an empty directory, full dotnet test (net8.0 and net10.0): 51 + 51 files left behind before, none after. All tests pass.

🤖 Generated with Claude Code

A test run left 51 files in the temporary directory per target framework,
88 MB each time. Most are the fixtures TestUtils.PrepareTestFile writes with
the HDF5 C library: its callers keep reading them after it returns, so it now
records every path it hands out and deletes them when the test process exits.
The rest are tests that create a file and never remove it - the writing link
tests, the circular reference test, and the external file of the external
link tests - which now delete it in a finally block like the other writing
tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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