3

I'm using meson and ninja as build system in my C++ project and I've configured catch2 as testing framework. I was wondering how to perform code coverage with the tests that I've written. I read this page, https://mesonbuild.com/Unit-tests.html but seems pretty unclear to me, can anybody help?

Antonio La Marra
  • 5,949
  • 4
  • 15
  • 23
  • install Gcovr then add `-Db_coverage=true` to your meson command line. Is there something specific you dont understand? – Alan Birtles Nov 27 '19 at 15:43
  • 1
    I've installed Gcovr, and run meson build --reconfigure -Db_coverage=true, then in the build folder I run the meson test command, but no coverage file has been generated – Antonio La Marra Nov 28 '19 at 10:04

1 Answers1

3

You should use one of coverage related targets: coverage-text, coverage-html, coverage-xml as described here. Or just coverage that tries all of these if possible:

$ ninja coverage -C builddir

Results are written to ./builddir/meson-logs directory.

Note that to produce html coverage reports you need lcov and genhtml binaries which are installed by lcov package.

pmod
  • 10,450
  • 1
  • 37
  • 50