I tried using an std.Io,File.stdout() in a test, but that just made it hang. After I swapped to stderr() I’m getting false positive.
Test in question:
test "Time struct formatting" {
var arena_allocator = heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena_allocator.deinit();
const alloc = arena_allocator.allocator();
// Setup IO (Required for clock.now)
var io_init = std.Io.Threaded.init(alloc, .{ .environ = .empty });
const io = io_init.io();
var t = std.debug.lockStderr(&.{}).terminal();
const writer = t.writer;
// Create the Time instance
const tnow = Time.create(io);
// Test 'now()'
try writer.print("{f}\n", .{tnow.fmt(.now)});
try writer.flush();
// Test 'syslog()'
try writer.print("{f}\n", .{tnow.fmt(.syslog)});
try writer.flush();
}
Result
j.markovic@MacBook-Pro-2 ~/GIT/wg-forwarder/src (git)-[0.16] % zig build test
test
└─ run test w
2026-01-14 21:40:02.984
Jan 14 21:40:02
failed command: /Users/j.markovic/GIT/wg-forwarder/.zig-cache/o/fba84e2a50f15a5f890340a18b20380d/test --cache-dir=/Users/
j.markovic/GIT/wg-forwarder/.zig-cache --seed=0x7805701c --listen=-
Any way to print stuff in testing with out getting false positive?