Zig NEWS

Discussion on: Code Coverage for Zig

Collapse
 
lisael profile image
Lisael • Edited

completely unused functions don’t contribute to the ‘executable lines’ total

Same with comptime logic. At first, I thought it would be fairly simple to write a tool that updates kcov result to add unused functions, but thinking about it, we can't say, looking at the coverage result file if comptime code was used or not.

It's no longer 'find every function declaration that doesn't have coverage info and count the function as nuncovered'. We have to tell if each line of code is comptime or not and check if it was used. Basically, rewrite parts of the compiler.

There is no way we get accurate coverage reports without implementing a bit of the logic into the compiler itself.

EDIT: that said, thanks for the post, I use this in my projects, with great benefits since I read it months ago :).