Is there a way to focus lcov code coverage reports to just one or two directories?

后端 未结 3 1383
长情又很酷
长情又很酷 2020-12-24 02:03

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 file

3条回答
  •  甜味超标
    2020-12-24 02:30

    A possible approach is to constrain which files are compiled with the coverage flags (-fprofile-arcs -ftest-coverage). If you don't want to engineer your make file system to be selective about which files are built with test instrumentation, the following trick might work for you:

    • Build your application without instrumentation.
    • Remove the .o files for source that you want to instrument
    • Turn on instrumentation and rebuild. Only the deleted object files will be rebuilt with instrumentation.
    • Run lcov

    This should result in only the targeted areas emitting gcov artifacts, which are blindly consumed by the lcov scripts.

提交回复
热议问题