From: Martin Gysel <me@bearsh.org>
Date: Thu, 19 Nov 2020 07:04:10 +0100
Subject: [PATCH 1/2] add test feature and make tests optional

---
 meson.build       | 14 ++++++++++----
 meson_options.txt |  4 ++++
 2 files changed, 14 insertions(+), 4 deletions(-)

Patch-Source: https://github.com/gentoo/gentoo/blob/3b3bd2d66b15d3ec1c8b2a41043cfc2e6aa0f738/sys-auth/fprintd/files/fprintd-1.90.7_0001-add-test-feature-and-make-tests-optional.patch

diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -137,7 +137,7 @@
 polkit_policy_directory = polkit_gobject_dep.get_pkgconfig_variable('policydir')
 
 # Tests dependencies
-pam_wrapper_dep = dependency('pam_wrapper', required: false)
+pam_wrapper_dep = dependency('pam_wrapper', required: false and get_option('test').enabled() )
 if get_option('pam') and not pam_wrapper_dep.found()
     warning('Dependency "pam_wrapper" required by test suite not found')
 endif
@@ -154,11 +154,13 @@
 }
 python3_available_modules = []
 
+if get_option('test').enabled()
 foreach module, required : python3_test_modules
     if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0
         warning('Python3 module \'' + module + '\' required by test suite not found')
     endif
 endforeach
+endif
 
 cdata = configuration_data()
 cdata.set_quoted('GETTEXT_PACKAGE', meson.project_name())
@@ -182,7 +184,9 @@
 if get_option('gtk_doc')
     subdir('doc')
 endif
-subdir('tests')
+if get_option('test').enabled()
+    subdir('tests')
+endif
 subdir('po')
 
 output = []
@@ -204,7 +208,9 @@
 output += '  Manuals: ' + get_option('man').to_string()
 output += '  GTK Doc: ' + get_option('gtk_doc').to_string()
 output += '  XML Linter ' + xmllint.found().to_string()
-output += '\nTest setup:\n'
-output += '  With address sanitizer: ' + address_sanitizer.to_string()
+if get_option('test').enabled()
+    output += '\nTest setup:\n'
+    output += '  With address sanitizer: ' + address_sanitizer.to_string()
+endif
 
 message('\n'+'\n'.join(output)+'\n')
diff --git a/meson_options.txt b/meson_options.txt
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,3 +23,7 @@
     type: 'boolean',
     value: false,
     description: 'Use gtk-doc to build documentation')
+option('test',
+    type: 'feature',
+    value: 'disabled',
+    description: 'Enable tests')
