I recently started using lcov to visualize my code coverage. It's a great tool.
One thing I'm noticing is that it generates code coverage reports for all the files that I'm using - including those that I'm not interested in. For example, it will give me code coverage reports for boost and mysql++ files.
Is there an easy way to force lcov to only generate coverage reports for specific files?
I have tried using the -k parameter like so:
/usr/bin/lcov -q -c -i -b . -d .obj -k src/ -k include/ -o app_base.info {run unit tests now} /usr/bin/lcov -q -c -b . -d .obj -k src/ -k include/ -o app_test.info /usr/bin/lcov -q -a app_base.info -a app_test.info -o app_total.info /usr/bin/genhtml -q -o lcov_output_directory app_total.info
(Meaning that I only want coverage files for the "include" and "src" directories.)
However, this doesn't seem to work. The report still shows me all the extraneous files. Any suggestions are very much appreciated. Thanks!
Lcov is a graphical front-end for gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure. Lcov supports statement, function, and branch coverage measurement.
You need to re-enable it by either: editing your ~/. lcovrc file (copied from /etc/lcovrc) to change lcov_branch_coverage setting to 1. adding --rc lcov_branch_coverage=1 to your lcov command lines.
You just need to install the Dart and lcov-info packages. Then you load your project folder and press Ctrl+Alt+c , coverage will be displayed with a summary of the whole projects coverage and also with specific line highlighting.
I used the --no-external
flag together with the --directory
flag to exclude unwanted files.
The definition of external from the man:
External source files are files which are not located in one of the directories specified by --directory or --base-directory.
So my command looked like this:
$ lcov --directory src -c -o report.info --no-external Capturing coverage data from src Found gcov version: 4.2.1 Scanning src for .gcda files ... Found 4 data files in src Processing src/C####.gcda ignoring data for external file /usr/include/c++/4.2.1/bits/allocator.h
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With