zig icon indicating copy to clipboard operation
zig copied to clipboard

`std.log.err` failing tests is unexpected behavior

Open BrainBlasted opened this issue 7 months ago • 1 comments

Often one wants to write unit tests that code handles error paths correctly. In many such cases, one would also log the error to stderr. If you have tests that call a function that calls std.log.err, your tests fail... Which is somewhat odd if logging that error is exactly what you wanted to happen. Currently to work around this developers need to make their own test_runner.zig to change this behavior.

Here's where the failure happens: https://github.com/ziglang/zig/blob/master/lib/compiler/test_runner.zig#L262

BrainBlasted avatar May 22 '25 22:05 BrainBlasted

Related https://github.com/ziglang/zig/issues/5738

nektro avatar May 22 '25 22:05 nektro