Tuesday, July 22, 2014

Code coverage - HTML reports using LCOV on windows

After generating code coverage there is a need to present the data in form other than gcov text files. There is a plugin (gcov plugin) for eclipse that it used for visualization but what when somebody without eclipse would like to view the reports?
There is a very good tool called LCOV which consists of: lcov and geninfo which provide a file with code coverage data and genhtml which transforms the coverage file to set of html files.
The problem is that these scripts are written for Linux environment and use Perl.
To run them on windows it is needed to:
  1. Install Perl (preferably under C:\Perl)
  2. Associate perl scripts with perl - very important is not to use windows association but to use commands:
    assoc .perl=Perl.File
    ftype Perl.File=C:\Perl\bin\perl.exe "%1" %*

    After associating files under windows the arguments are not passed?
  3. Download of the modified script available here.


After finishing these steps it is possible to invoke perl scripts by simply using windows command line and typing for example:
C:\Perl\bin\Perl.exe lcov.perl --capture --directory Debug --output-file debug/coverage.info --rc lcov_branch_coverage=1
in order to generate file with code coverage and typing:
C:\Perl\bin\Perl.exe genhtml.perl --output HTML debug/coverage.info --demangle-cpp --prefix %~dp0 --function-coverage --branch-coverage --show-details
to generate html reports.

Code coverage HTML report LCOV on windows 7

Code coverage HTML report LCOV on windows 7

3 comments :

  1. Nice to read this article will be very helpful in the future, share more info with us. Good job! responsive web development

    ReplyDelete
  2. Excellent it works perfectly, thanks a lot for publishing that!

    ReplyDelete
  3. some tips please, it doesnt work for me, first i got errors referring the PWD, which I corrected with getcwd(), but then the errors keep coming and coming.

    ReplyDelete