I haven’t tried it myself, but you might be able to spit out a generated source file and have a subsequent build step depend on it.
My idea would be textual code generation, though, which might be a tad flaky. Though at least you’d be able to see the files the codegen output.
I don’t know if Zig has any other code generation method available yet or not, besides textual. It can generate types. Haven’t tried it with tests. I don’t know if they’re as “first class” as compile-time type is, yet.
As someone who has a background in writing test automation full time, I see the value of very big test suites. But also consider that one of the cool things about Zig is being able to put tests RIGHT next to the code it tests, and use them as a sort of documentation. Even if you’re going to build a big test suite (please do), make sure you put a few doc tests along side the functions you’re writing as well.
Code gen is definitely a solution, although I agree that it is a tad flaky as you mention.
Based on your reply, I will probably have a read through the standard library code base to see if you can do something similar to what you can do with @Type , that’s a great idea.
Responding on your point on test as documentation, to further contextualize my question, what I am writing is a comptime TOML parser that parses TOML to a Zig type (with again, @Type). To verify the library, I plan to use an existing test suite (consisting of TOML and JSON file pairs). Rather than porting each test to Zig (cumbersome + error prone, there are 500+ or so tests), I plan to automatically generate them with Zigs amazing comptime capabilities .