From 96ba9f4d8d747889a10e1a84594922e25fde495c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 21 Apr 2022 18:51:09 +0100 Subject: [PATCH] tests: Optionally skip building and running the actual tests If we're building libglnx as a subproject in a larger project, we won't necessarily want to run these. Signed-off-by: Simon McVittie --- meson_options.txt | 9 +++++++++ tests/meson.build | 42 ++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 meson_options.txt diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..1028017f --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,9 @@ +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: LGPL-2.0-or-later + +option( + 'tests', + type : 'boolean', + description : 'build and run unit tests', + value : 'true', +) diff --git a/tests/meson.build b/tests/meson.build index 555009f2..2c38ab09 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -21,24 +21,26 @@ libglnx_testlib_dep = declare_dependency( link_with : libglnx_testlib, ) -test_names = [ - 'errors', - 'fdio', - 'macros', - 'shutil', - 'xattrs', -] +if get_option('tests') + test_names = [ + 'errors', + 'fdio', + 'macros', + 'shutil', + 'xattrs', + ] -foreach test_name : test_names - exe = executable(test_name, - [ - 'test-libglnx-' + test_name + '.c', - ], - dependencies: [ - libglnx_dep, - libglnx_deps, - libglnx_testlib_dep, - ], - ) - test(test_name, exe) -endforeach + foreach test_name : test_names + exe = executable(test_name, + [ + 'test-libglnx-' + test_name + '.c', + ], + dependencies: [ + libglnx_dep, + libglnx_deps, + libglnx_testlib_dep, + ], + ) + test(test_name, exe) + endforeach +endif