Meson comes with a fully functional unit test system. To use it simply build an executable and then use it in a test.
e = executable('prog', 'testprog.c')
add_test('name of test', e)
You can add as many tests as you want. They are run with the command ninja test.
Meson captures the output of all tests and writes it in the log file meson-private/testlog.txt.
It is currently not possible to define command line arguments or environment variables to use when running the tests. This functionality will be added in a later release.
If you enable coverage measurements by giving Meson the command line flags --enable-gcov, you can generate coverage reports. Meson will autodetect what coverage generator tools you have installed and will generate the corresponding targets. These targets are coverage-xml and coverage-text which are both provided by Gcovr and coverage-html, which requires Lcov and GenHTML.
The the output of these commands is written to the log directory meson-logs in your build directory.
If you have Valgrind installed, Meson will provide a test-valgrind target, which runs all your unit tests under Valgrind. The full Valgrind log can be found in meson-logs/testlog-valgrind.txt