有没有办法将 lcov 代码覆盖率报告集中到一个或两个目录?
我最近开始使用 lcov 来可视化我的代码覆盖率。 这是一个很棒的工具。
我注意到的一件事是,它为我正在使用的所有文件生成代码覆盖率报告 - 包括那些我不感兴趣的文件。例如,它将为我提供 boost 和 mysql++ 文件的代码覆盖率报告。
有没有一种简单的方法可以强制 lcov 仅生成特定文件的覆盖率报告?
我尝试过使用 -k 参数,如下所示:(
/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
这意味着我只需要“include”和“src”目录的覆盖文件。)
但是,这似乎不起作用。 该报告仍然向我显示所有无关的文件。 非常感谢任何建议。 谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用
--no-external
标志和--directory
标志来排除不需要的文件。男人对外在的定义:
所以我的命令看起来像这样:
I used the
--no-external
flag together with the--directory
flag to exclude unwanted files.The definition of external from the man:
So my command looked like this:
lcov 支持命令行参数--remove 完全按照您的要求去做。
lcov supports a command line argument --remove to do exactly what you are asking for.
一种可能的方法是限制使用覆盖标志(-fprofile-arcs -ftest-coverage)编译哪些文件。 如果您不想将 make 文件系统设计为选择性地选择使用测试仪器构建哪些文件,则以下技巧可能适合您:
这应该会导致仅目标区域发出 gcov 伪影,这些伪影会被 lcov 脚本盲目消耗。
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:
This should result in only the targeted areas emitting gcov artifacts, which are blindly consumed by the lcov scripts.