1

I am trying to get a coverage report in meson. According to the documentation, it should be this simple:

First, initialize the build directory with this command.

$ meson <other flags> -Db_coverage=true

Then issue the following commands.

$ meson compile
$ meson test
$ meson compile coverage-html (or coverage-xml)

The coverage report can be found in the meson-logs subdirectory.

However, it does not work for me. All steps are okay, except for the last:

$ meson compile coverage_html

ERROR: Can't invoke target `coverage_html`: target not found

Any idea about this?

wovano
  • 4,543
  • 5
  • 22
  • 49
  • 1
    `coverage-html` or `coverage_html` ? – Morten Jensen Oct 27 '21 at 10:24
  • Same result in both cases. >> meson compile coverage-html ERROR: Can't invoke target `coverage-html`: target not found >> meson compile coverage_html ERROR: Can't invoke target `coverage_html`: target not found – David Marcos Oct 27 '21 at 13:36
  • 1
    Which backend are you using, ninja, xcode, or msbuild? Have you tried invoking them directly through the backend, ie, `ninja -C builddir coverage-html`? – dcbaker Oct 28 '21 at 02:17

1 Answers1

3

It looks that part of reference is outdated, I am using ninja backend and have the same behavior:

$ meson compile coverage-text -C build

ERROR: Can't invoke target `coverage-text`: target not found

However invoking target directly works:

$ 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
...

Also check if option is correctly setup

$ meson configure build | grep cover  
  b_coverage          true        

and if you have lcov or gcovr installed

So, the current (minimal) steps to test with coverage report should be:

$ 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
pmod
  • 10,450
  • 1
  • 37
  • 50