eddyxu / cpp-coveralls

Upload gcov results to coveralls.io
Apache License 2.0
282 stars 74 forks source link

Incorrect results for inlined functions #54

Open ptomulik opened 10 years ago

ptomulik commented 10 years ago

WIth defaul options the hit counts for inline functions (or class methods defined in headers) are usually inacurrate. This usually happens when a function is referred by more than one module, all being in same directory. The reason is that gcov overrides its *.gcov files. A remedy for this is to use -l gcov option, i.e:

coveralls --gcov-options '\-l'

IMHO, a good common practice would be to use also -p gcov option (preserve paths).

I think this is worth to be mentioned in documentation (README). This may save many troubles to people using cpp-coveralls.

briangreenery commented 10 years ago

I just ran into this also. Using --gcov-options '\-lp' fixed it for me too. It seems like gcovr avoids this by parsing the gcov files immediately after running gcov.

tysonite commented 10 years ago

Unfortunately, adding --gcov-options '-lp' does not work for me. I tried this proposal in my project tysonite/asn1-complier, but I still got incomplete coverage information for header files (.hh).

Comparing the results of code coverage of local "lcov" and "cpp-coveralls" / coveralls.io show different results.

ptomulik commented 10 years ago

Did you noted the backslash '\' before '-lp'? I remember, it was important (but can't recall how it affected the output at the moment).

tysonite commented 10 years ago

Yes, it is a misprint in my previous comment. I did similar what you wrote in a top post, look here: https://github.com/tysonite/asn1-compiler/blob/master/.travis.yml

briangreenery commented 10 years ago

@tysonite Looking at your travis file, it looks like you're excluding all CMakeFiles directories and the tests directories. However, that's where all of the coverage files get output to, and the --exclude option will prevent cpp-coveralls from including any coverage files found in those directories. I think if you remove those excludes it should pick up everything. Like, here's where the coverage files end up for your project.

Maybe the --exclude option should be changed to only work on the source file path and not the path of the .gcno file?

tysonite commented 10 years ago

@briangreenery, thank you for your help and time. I removed all "--exclude" options from cpp-coveralls command line and now see the full coverage report.

I will need to refine .travis.yml somehow in order to remove unneeded files from the overall report. However, it is not clear for me when I look at the README.md that ".gcno" files will be excluded, I thought that final coverage report will not include statistics for the excluded file/directory.