Basic std.Io.File.stdout (0.16)

For tests there is another option, write your own test runner which handles print to stdout and/or stderr differently (however you like it to be handled).

For example I wrote a custom test runner for testing raylib examples where I run the test in a subprocess and capture stdout and stderr, but I only show that output if the test signaled via non-zero exit code that it should be considered a test failure. (Because treating output as an error isn’t useful in every testing scenario and by using a custom test runner you can decide what should happen with stdout/stderr)

I found these resources useful while writing my custom test runner:
https://www.openmymind.net/Using-A-Custom-Test-Runner-In-Zig/
Zig - Creating and using a custom test runner is easy!

2 Likes