How do I get zig build to Run all the tests?

I think the way to do this is using std.testing.refAllDecls(). Basically as long as you reference varint and any other module you want tested in your root.zig, you can use that function so that the semantic analyzer sees them:

// root.zig
const varint = @import("...");

test {
    std.testing.refAllDecls(@This());
}

I believe this only works for public declarations, and I read elsewhere that this is basically a temporary hack anyway, so there will likely be a cleaner way in the future.

2 Likes