gpt4 book ai didi

code-coverage - 使用 lcov 报告代码覆盖率时出错

转载 作者:行者123 更新时间:2023-12-02 16:14:30 28 4
gpt4 key购买 nike

更新到 Ubuntu 16.04 后,我正在尝试对我的项目进行覆盖。我明白

Deleted 665 files
Writing data to coverage.info.cleaned
lcov: ERROR: cannot write to coverage.info.cleaned!
CMakeFiles/coverage.dir/build.make:57: recipe for target 'CMakeFiles/coverage' failed
make[3]: *** [CMakeFiles/coverage] Error 13
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/coverage.dir/all' failed
make[2]: *** [CMakeFiles/coverage.dir/all] Error 2
CMakeFiles/Makefile2:74: recipe for target 'CMakeFiles/coverage.dir/rule' failed
make[1]: *** [CMakeFiles/coverage.dir/rule] Error 2
Makefile:129: recipe for target 'coverage' failed
make: *** [coverage] Error 2
enter code here

更新之前,我运行覆盖范围没有问题

最佳答案

在将文件传递给 lcov 时使用绝对路径而不是相对路径会有帮助吗?

我遇到了类似的问题,lcov 也无法写入文件。不确定这是否是 lcov 中的错误,但问题是它与相对路径混淆了:

lcov -a test_fast_cxxtest_gcov__base.info -a test_fast_cxxtest_gcov__test.info \
-o test_fast_cxxtest_gcov__total.info
Combining tracefiles.
Reading tracefile test_fast_cxxtest_gcov__base.info
Reading tracefile test_fast_cxxtest_gcov__test.info
lcov: WARNING: function data mismatch at /home/phil/ghost/constants.h:1862
Writing data to test_fast_cxxtest_gcov__total.info
lcov: ERROR: cannot write to test_fast_cxxtest_gcov__total.info!

使用 strace 运行它,发现它在多个位置执行 chdir("/"),这会将工作目录更改为 /。这解释了为什么它无法写入文件。

一种解决方法是使用绝对路径。例如,如果您使用 GNU make,则可以使用 abspath 命令:

lcov -a $(abspath test_fast_cxxtest_gcov__base.info) \
-a $(abspath test_fast_cxxtest_gcov__test.info) \
-o $(abspath test_fast_cxxtest_gcov__total.info)

修改后,终于可以写入文件了。

(据我所知,尝试使用 --base-directory--directory 选项设置目录等其他选项没有效果。我测试的lcov版本是1.12。)

这个问题不仅限于 Ubuntu,我在 Arch Linux 上也遇到过这个问题。不过,这可能是 1.12 中引入的回归,因此我报告了它(请参阅 issue #77630 )。

更新: Lcov 不是 GCC 的一部分,因此我最初的错误报告已关闭,但我从 Lcov 邮件列表中得到了答案。该问题已在提交 632c25 中修复。基于 Arch Linux 的发行版的用户可以使用 aur/lcov-git 尝试最新的快照。 .

关于code-coverage - 使用 lcov 报告代码覆盖率时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37675961/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com