aboutsummaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorThomas Heijligen <thomas.heijligen@secunet.com>2022-04-25 19:22:44 +0200
committerThomas Heijligen <src@posteo.de>2022-05-12 08:53:01 +0000
commit400a6a8b2c7a6fcdbca5397ac0cc58244896732d (patch)
tree34b5c5c95f217ecef2e96bab1cfab0a43ff5ad9f /meson.build
parentb0aec45d8c9027c2fca52254a1e437036547a0d0 (diff)
downloadflashrom-400a6a8b2c7a6fcdbca5397ac0cc58244896732d.tar.gz
flashrom-400a6a8b2c7a6fcdbca5397ac0cc58244896732d.tar.bz2
flashrom-400a6a8b2c7a6fcdbca5397ac0cc58244896732d.zip
meson: add option to disable tests
During development it can be useful to disable unit testing. By default tests are built if cmocka is found. To force enable tests run `meson build -Dtests=enable`. To disable tests run `meson build -Dtests=disabled`. Change-Id: I384c904c577b265dfe36bf46bf07c641bc29de9b Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/63832 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build53
1 files changed, 29 insertions, 24 deletions
diff --git a/meson.build b/meson.build
index f9a0455d..a783bdda 100644
--- a/meson.build
+++ b/meson.build
@@ -506,30 +506,35 @@ executable(
subdir('util')
+# Use `.auto() or .enabled()` instead of `.allowed()` to keep the minimum meson version as low as possible.
+# `.allowed()` gets introduced in 0.59.0
+if get_option('tests').auto() or get_option('tests').enabled()
# unit-test framework
cmocka_dep = dependency(
- 'cmocka',
- fallback: ['cmocka', 'cmocka_dep'],
- required: false
-)
-flashrom_test_dep = declare_dependency(
- include_directories : include_dir,
- sources : [
- srcs,
- 'cli_common.c',
- 'cli_output.c',
- 'flashrom.c',
- ],
- compile_args : [
- '-includestdlib.h',
- '-includeunittest_env.h',
- '-includehwaccess_x86_io_unittest.h'
- ],
- dependencies : [
- deps,
- ],
-)
-
-if cmocka_dep.found()
- subdir('tests')
+ 'cmocka',
+ fallback: ['cmocka', 'cmocka_dep'],
+ required : get_option('tests')
+ )
+
+ flashrom_test_dep = declare_dependency(
+ include_directories : include_dir,
+ sources : [
+ srcs,
+ 'cli_common.c',
+ 'cli_output.c',
+ 'flashrom.c',
+ ],
+ compile_args : [
+ '-includestdlib.h',
+ '-includeunittest_env.h',
+ '-includehwaccess_x86_io_unittest.h'
+ ],
+ dependencies : [
+ deps,
+ ],
+ )
+
+ if cmocka_dep.found()
+ subdir('tests')
+ endif
endif