有没有一种方法可以将lcov代码覆盖率报告仅集中到一个或两个目录? [英] Is there a way to focus lcov code coverage reports to just one or two directories?

查看:609
本文介绍了有没有一种方法可以将lcov代码覆盖率报告仅集中到一个或两个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用lcov可视化我的代码覆盖率.这是一个很棒的工具.

I recently started using lcov to visualize my code coverage. It's a great tool.

我要注意的一件事是,它将为我正在使用的所有文件(包括我不感兴趣的文件)生成代码覆盖率报告.例如,它将为我提供boost和mysql ++的代码覆盖率报告文件.

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.

是否有一种简单的方法可以强制lcov仅生成特定文件的覆盖率报告?

Is there an easy way to force lcov to only generate coverage reports for specific files?

我曾尝试使用-k参数,如下所示:

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

(意思是我只想要"include"和"src"目录的覆盖率文件.)

(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 支持命令行参数-remove 来精确执行您的要求.

lcov supports a command line argument --remove to do exactly what you are asking for.

这篇关于有没有一种方法可以将lcov代码覆盖率报告仅集中到一个或两个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆