我正在尝试获得介子的覆盖报告。根据文档,它应该这么简单:
首先,用这个命令初始化构建目录。
$ meson <other flags> -Db_coverage=true
然后发出以下命令:
$ meson compile
$ meson test
$ meson compile coverage-html (or coverage-xml)
覆盖率报告可以在meson-logs子目录中找到。
然而,它不适合我。所有步骤都可以,除了最后一个:
$ meson compile coverage_html
ERROR: Can't invoke target `coverage_html`: target not found
有什么想法吗?
看起来部分引用是过时的,我使用忍者后端并具有相同的行为:
$ meson compile coverage-text -C build
ERROR: Can't invoke target `coverage-text`: target not found
但是直接调用target也可以:
$ ninja coverage-html -C build
ninja: Entering directory `build'
[1/1] Generates HTML coverage report
LLVM (http://llvm.org/):
LLVM version 7.0.1
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: haswell
lcov: LCOV version 1.13
genhtml: LCOV version 1.13
Capturing coverage data from /home/<>/build
Found gcov version: 8.3.0
Scanning /home/<>/build for .gcno files ...
Found 212 graph files in /home/<>/build
Processing aaa.p/bbb.cc.gcno
...
还要检查选项是否正确设置
$ meson configure build | grep cover
b_coverage true
如果你有lcov或gcovr安装
所以,当前(最小的)测试覆盖率报告的步骤应该是:
$ meson setup build -Db_coverage=true
$ meson test -C build
$ ninja coverage-html -C build
# or coverage-xml or coverage-text, or just 'coverage' which should generate all 3 if possible