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:

I had been using that, though, as you note, it only seems to be discovering public attributes, though that might be because i wasn’t using them.

My concern with this is, as you state, refAllDecls has been declared to be a hack. I wasn’t sure if this “hack” had had a candidate for replacement yet. Looks like not yet.

When running tests, each test source is cached, on the next run if the tests are the same they don’t run.
My recommendation is to use a mode that prints a summary about the tests that actually run (new or changed tests in addition to the failed tests):

I didn’t know about the new option. I had been using all but sometimes it’s hard to know if the file i’m actually working on is being tested. New might be able to fix that.

2 Likes