meson: improve test handling

Tests will now be built at `meson test`-time, so there's no cost if the
user isn't going to run them.

This is better than guarding on build type, as distros may want to test production
builds before shipping.

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2026-07-24 07:37:41 +01:00
parent cf958091ad
commit 87087ded64
2 changed files with 4 additions and 5 deletions
+1 -4
View File
@@ -317,7 +317,4 @@ if get_option('build_apps') and host_machine.system() != 'windows'
subdir('apps') subdir('apps')
endif endif
# Optional tests subdir('tests')
if get_option('buildtype') == 'debug'
subdir('tests')
endif
+3 -1
View File
@@ -4,6 +4,7 @@ test_lib = static_library(
objects: libjson.extract_all_objects( objects: libjson.extract_all_objects(
recursive: false, recursive: false,
), ),
build_by_default: false,
install: false, install: false,
) )
@@ -65,7 +66,8 @@ foreach t : test_cases
name = t[0] name = t[0]
expected = t[1] expected = t[1]
exe = executable(name, name + '.c', exe = executable(name, name + '.c',
dependencies: test_deps dependencies: test_deps,
build_by_default: false
) )
test(name, exe, test(name, exe,