Code Coverage for Zig with Callgrind
ryanliptak.com
ryanliptak.com
I have previously used kcov [1] to perform coverage testing which due to zig having good DWARF debugging information worked with no fanfare. However, I'm not too familiar with the shortcomings of this method vs. the more fully instrumented binary approach provided.
- Running the zig std lib tests normally takes ~5 seconds
- Running the zig std lib tests with callgrind takes ~2 minutes
- Running the zig std lib tests with kcov takes ~9 seconds
There are also slight disagreements in terms of the results:
- grindcov reports 43480 of 52586 lines executed or 82.68% coverage
- kcov reports 44103 of 52335 lines executed or 84.3% coverage
This difference might be down to kcov following child processes while grindcov doesn't, but I'm not totally sure.
kcov is probably the better choice overall.
It's one of those fundamental things that should just work the same across every ecosystem.
Sorry for the possibly silly question but I did not understand if Zig has a Rust similar concept of "borrow" for pointers, of it is based on static analysis of allocator?
Zig seems to me easier to use than Rust on this respect, but I cannot understand the difference (because I do not know them very well)
Reasonable people can disagree.
Reader mode was a savior, here.
EDIT: Done.