Skip to content

test(proc): clean up the fixture directory on setup failure - #41

Merged
HaoZeke merged 1 commit into
mainfrom
test/proc-fixture-failure-cleanup
Nov 19, 2026
Merged

HaoZeke merged 1 commit into
mainfrom
test/proc-fixture-failure-cleanup

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

makeExecFixture creates its scratch directory under .zig-cache and
then allocates the fixture file paths. When one of those allocations
fails, the function frees its paths and returns error.OutOfMemory, but
the directory .zig-cache/zig-common-proc-fixture-<tag>-<pid> stays
behind.

makeExecFixture removes the directory through an errdefer that runs
before the path is freed. That errdefer passes std.heap.page_allocator
to fsx.deleteTree, because the removal allocates and a failing caller
allocator would stop it. ExecFixture.deinit takes the caller allocator
and replaces the separate cleanup defers in the proc fixture tests.

The new test
makeExecFixture removes scratch directories after setup failures in
src/proc.zig checks that every failing allocation index leaves no
fixture directory and that at least one failing index comes after the
directory exists.

`makeExecFixture` creates its scratch directory under `.zig-cache` and
then allocates the fixture file paths. When one of those allocations
fails, the function frees its paths and returns `error.OutOfMemory`, but
the directory `.zig-cache/zig-common-proc-fixture-<tag>-<pid>` stays
behind.

`makeExecFixture` removes the directory through an errdefer that runs
before the path is freed. That errdefer passes `std.heap.page_allocator`
to `fsx.deleteTree`, because the removal allocates and a failing caller
allocator would stop it. `ExecFixture.deinit` takes the caller allocator
and replaces the separate cleanup defers in the proc fixture tests.

The new test
`makeExecFixture removes scratch directories after setup failures` in
`src/proc.zig` checks that every failing allocation index leaves no
fixture directory and that at least one failing index comes after the
directory exists.
@HaoZeke
HaoZeke merged commit adc18a4 into main Nov 19, 2026
8 checks passed
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