[libglnx/wip/smcv/subproject: 2/4] tests: Optionally skip building and running the actual tests




commit 2adc8c5358f5083953c028043309815458f13dcd
Author: Simon McVittie <smcv collabora com>
Date:   Thu Apr 21 18:33:32 2022 +0100

    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 <smcv collabora com>

 meson_options.txt |  9 +++++++++
 tests/meson.build | 40 +++++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..1028017
--- /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 d60563f..dbb4a01 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -17,23 +17,25 @@ libglnx_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,
-    ],
-  )
-  test(test_name, exe)
-endforeach
+  foreach test_name : test_names
+    exe = executable(test_name,
+      [
+        'test-libglnx-' + test_name + '.c',
+      ],
+      dependencies: [
+        libglnx_dep,
+        libglnx_deps,
+      ],
+    )
+    test(test_name, exe)
+  endforeach
+endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]