Skip to content
Latchkey

meson test: Run Meson Test Suites in CI

meson test -C <builddir> runs the tests declared with test() in meson.build, and --print-errorlogs shows the log of any that fail.

Meson has a built-in test runner, no separate tool needed. In CI the key flag is --print-errorlogs so a failing test shows its output in the job log.

What it does

meson test runs the tests registered by test() in the build directory, reporting results and writing a log under meson-logs/testlog.txt. It can filter by suite and run tests in parallel.

Common usage

Terminal
meson test -C build --print-errorlogs
meson test -C build --suite unit
meson test -C build --num-processes 4 --timeout-multiplier 2

Options

FlagWhat it does
--print-errorlogsPrint the log of tests that failed
--suite <name>Run only tests in the named suite
--num-processes <N>Run N tests in parallel
--timeout-multiplier <x>Scale test timeouts (slow CI runners)
-C <dir>Build directory to run tests from
--wrapper <cmd>Run tests under a wrapper such as valgrind

In CI

Always add --print-errorlogs; without it a failure shows only the test name. On slow shared runners, --timeout-multiplier 2 avoids false timeouts. The full log lives at build/meson-logs/testlog.txt; upload it as a CI artifact for post-mortems.

Common errors in CI

"No tests defined." means meson.build has no test() calls or you ran from the wrong build dir. "ERROR: Directory ... is not a Meson build directory." means setup was not run. Timeouts reported as "TIMEOUT" on slow runners are fixed with --timeout-multiplier. Tests that pass locally but fail in CI often depend on an installed binary the runner lacks.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →