您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

无法使用lcov生成覆盖率报告

无法使用lcov生成覆盖率报告

幸运的是,答案是肯定的,这是可能的。我收到了lcov开发人员的答复,为我提供了解决方案,谢谢Peter!

他指出,所有源代码路径在编译步骤中都会硬编码到.gcno文件中。但是,尽管没有找到源文件(并产生警告),但lcov仍将仅基于.gcda和.gcno文件中的数据来生成代码覆盖率输出,即使找不到源代码也是如此。但是,genhtml步骤将失败,因为它无法找到要用代码覆盖率数据进行注释的源代码

解决方案是使用lcov的“ geninfo_adjust_src_path”配置设置。通过使用此设置,指示lcov在写入输出.info文件时将.gcno文件中找到的源代码路径更改为正确的源代码路径。因此,就我而言:

lcov -d BUILD/app/packages/ --capture --no-external --output-file app.info
     --rc geninfo_adjust_src_path="/var/lib/jenkins/workspace/App-Coverage/BUILD/ 
     => /var/lib/jenkins/workspace/App-Coverage-Unittest/BUILD/"

The warnings “Cannot open source file” will still be there when invoking lcov, but the resulting .info file will contain the correct paths and can therefore be converted to HTML on the test machine using genhtml.

其他 2022/1/1 18:17:27 有481人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶