Skip to content

automatically test for out of memory conditions when std.testing.allocator is used #22086

@andrewrk

Description

@andrewrk

Zig already has checkAllAllocationFailures for doing this, however it is opt-in.

I propose to make the test runner enable this kind of testing by default. When it makes an allocation fail, it allows error.OutOfMemory to be returned from the unit test, but still checks for memory leaks.

A unit test could opt-out of this by not using std.testing.allocator or by setting a flag (i.e. std.testing.skipAllocationFailureChecking();).

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.testingThis issue is related to testing the compiler, standard library, or other parts of Zig.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions