-
Notifications
You must be signed in to change notification settings - Fork 3
[major] number of lines covered not accurate? #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
other example where I don't understand line count: |
should we have an option to discount it from line/function/branch coverage stats? otherwise it inflates the numbers |
I'm still digging this and it seems actually GCOV/LCOV might not be the perfect solution for code coverage. Simple example, 1 test file imports 1 function from another Nim file like so: ## Minimal nim file used in tests for checking compilation and coverage
import ../coco
echo get_cache_folder("foo.nim", "bar", 42) After compilation, we have a C file containing only the required function, not the whole Coco library: #line 18 "/Users/sam/Code/nim-coverage/coco.nim"
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, get_cache_folder_2hKxOP9bo6u9buKgLZs3GK2Q)(NimStringDesc* filename, NimStringDesc* nimcache, NI increment) {
NimStringDesc* result; NimStringDesc* fmtRes; nimfr_("get_cache_folder", "coco.nim"); result = (NimStringDesc*)0;
#line 19 "/Users/sam/Code/nim-coverage/coco.nim"
nimln_(19, "coco.nim");
#line 19 "/Users/sam/Code/nim-coverage/coco.nim"
#line 19 "/Users/sam/Code/nim-coverage/coco.nim"
fmtRes = rawNewString(((NI) 67));
# and so on.... And the LCOV.info contains only the following:
Resulting in a wrong coverage because there's only one function instead of everything. So either I need to parse Nim files by hand to consolidate the results or try to find X (compiler flags?) to generate C files more in sync with the Nim sources. |
whatever the right way is, this isn't it ;-) |
for each file bar.nim you want coverage on, generate a coverage_bar.nim with contents: include bar.nim |
with nim-lang/Nim#9560 at list you could list public symbols; but may not be exactly what's needed here |
Is the nim compiler removing dead code? |
Thanks for your suggestion. I tried the flag but it didn't help. Unfortunately I think this project is out of my reach as I'm totally new to Nim. |
Note: this was after running:
note: this may explain why (clicking on functions); but is quite confusing:
The text was updated successfully, but these errors were encountered: