Repository navigation
test(proc): clean up the fixture directory on setup failure - #41
Merged
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
makeExecFixturecreates its scratch directory under.zig-cacheandthen allocates the fixture file paths. When one of those allocations
fails, the function frees its paths and returns
error.OutOfMemory, butthe directory
.zig-cache/zig-common-proc-fixture-<tag>-<pid>staysbehind.
makeExecFixtureremoves the directory through an errdefer that runsbefore the path is freed. That errdefer passes
std.heap.page_allocatorto
fsx.deleteTree, because the removal allocates and a failing callerallocator would stop it.
ExecFixture.deinittakes the caller allocatorand replaces the separate cleanup defers in the proc fixture tests.
The new test
makeExecFixture removes scratch directories after setup failuresinsrc/proc.zigchecks that every failing allocation index leaves nofixture directory and that at least one failing index comes after the
directory exists.