mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2025-12-20 04:40:05 +01:00
tests: Skip tests when dependencies are missing
By default, just skip tests when a dependency is missing. However, for now do not allow disabling the tests and add an option to turn the skipping behaviour into an error (enabled in the CI). Closes: #133
This commit is contained in:
parent
ae04fa9897
commit
1fa6fb5c30
9 changed files with 44 additions and 21 deletions
|
|
@ -67,7 +67,7 @@ build_stable:
|
|||
stage: build
|
||||
allow_failure: true
|
||||
script:
|
||||
- meson _build
|
||||
- meson _build -Drequire_tests=true
|
||||
- ninja -C _build -v
|
||||
- ninja -C _build -v install
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ build_dev:
|
|||
- .install_libfprint_dev
|
||||
stage: build
|
||||
script:
|
||||
- meson _build --werror -Dgtk_doc=true
|
||||
- meson _build -Drequire_tests=true --werror -Dgtk_doc=true
|
||||
- ninja -C _build -v
|
||||
- ninja -C _build -v install
|
||||
artifacts:
|
||||
|
|
@ -92,7 +92,7 @@ test_dev:
|
|||
- .install_libfprint_dev
|
||||
stage: test
|
||||
script:
|
||||
- meson _build -Db_coverage=true
|
||||
- meson _build -Db_coverage=true -Drequire_tests=true
|
||||
- meson test -C _build --print-errorlogs --no-stdsplit --timeout-multiplier 3
|
||||
- ninja -C _build coverage
|
||||
- cat _build/meson-logs/coverage.txt
|
||||
|
|
@ -109,7 +109,7 @@ test_dev_with_sanitizer:
|
|||
- .install_libfprint_dev
|
||||
stage: test
|
||||
script:
|
||||
- meson _build -Db_sanitize=address
|
||||
- meson _build -Db_sanitize=address -Drequire_tests=true
|
||||
- meson test -C _build --print-errorlogs --no-stdsplit --timeout-multiplier 5
|
||||
artifacts:
|
||||
name: meson-logs
|
||||
|
|
|
|||
|
|
@ -153,7 +153,11 @@ python3_available_modules = []
|
|||
|
||||
foreach module, required : python3_test_modules
|
||||
if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0
|
||||
error('Python3 module \'' + module + '\' required by test suite not found')
|
||||
if not get_option('require_tests')
|
||||
warning('Python3 module \'' + module + '\' required to run (some) tests')
|
||||
else
|
||||
error('Python3 module \'' + module + '\' required by test suite not found')
|
||||
endif
|
||||
endif
|
||||
endforeach
|
||||
|
||||
|
|
|
|||
|
|
@ -23,3 +23,8 @@ option('gtk_doc',
|
|||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Use gtk-doc to build documentation')
|
||||
|
||||
option('require_tests',
|
||||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Make tests error out if a dependency is missing')
|
||||
|
|
|
|||
|
|
@ -32,13 +32,17 @@ import re
|
|||
import shutil
|
||||
import socket
|
||||
import struct
|
||||
import dbusmock
|
||||
import gi
|
||||
gi.require_version('FPrint', '2.0')
|
||||
from gi.repository import GLib, Gio, FPrint
|
||||
from output_checker import OutputChecker
|
||||
import cairo
|
||||
import signal
|
||||
from output_checker import OutputChecker
|
||||
try:
|
||||
import dbusmock
|
||||
import gi
|
||||
gi.require_version('FPrint', '2.0')
|
||||
from gi.repository import GLib, Gio, FPrint
|
||||
import cairo
|
||||
except Exception as e:
|
||||
print("Missing dependencies: %s" % str(e))
|
||||
sys.exit(1 if os.getenv('REQUIRE_TESTS') else 77)
|
||||
|
||||
try:
|
||||
from subprocess import DEVNULL
|
||||
|
|
@ -326,7 +330,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
|||
if 'POLKITD_MOCK_PATH' in os.environ:
|
||||
polkitd_template = os.path.join(os.getenv('POLKITD_MOCK_PATH'), 'polkitd.py')
|
||||
else:
|
||||
polkitd_template = os.path.join(os.path.dirname(__file__), 'dbusmock/polkitd.py')
|
||||
polkitd_template = os.path.join(os.path.dirname(__file__), 'dbusmock-services/polkitd.py')
|
||||
print ('Using template from %s' % polkitd_template)
|
||||
|
||||
self._polkitd, self._polkitd_obj = self.spawn_server_template(
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ foreach pt: python_tests
|
|||
suite: ut_suite,
|
||||
depends: pt.get('depends', []),
|
||||
workdir: pt.get('workdir', meson.build_root()),
|
||||
env: pt.get('env', []),
|
||||
env: pt.get('env', []) + (get_option('require_tests') ? ['REQUIRE_TESTS=1'] : []),
|
||||
timeout: pt.get('timeout', 30),
|
||||
is_parallel: pt.get('is_parallel', true),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,13 +15,17 @@ import tempfile
|
|||
import unittest
|
||||
import sys
|
||||
import subprocess
|
||||
import dbus
|
||||
import dbusmock
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import pypamtest
|
||||
try:
|
||||
import dbusmock
|
||||
import pypamtest
|
||||
import dbus
|
||||
except Exception as e:
|
||||
print("Missing dependencies: %s" % str(e))
|
||||
sys.exit(1 if os.getenv('REQUIRE_TESTS') else 77)
|
||||
|
||||
PAM_SUCCESS = 0
|
||||
PAM_AUTH_ERR = 7
|
||||
|
|
@ -62,7 +66,7 @@ class TestPamFprintd(dbusmock.DBusTestCase):
|
|||
template_path = './'
|
||||
if 'TOPSRCDIR' in os.environ:
|
||||
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
||||
klass.template_name = template_path + 'dbusmock/fprintd.py'
|
||||
klass.template_name = template_path + 'dbusmock-services/fprintd.py'
|
||||
print ('Using template from %s' % klass.template_name)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -15,13 +15,19 @@ import tempfile
|
|||
import unittest
|
||||
import sys
|
||||
import subprocess
|
||||
import dbus
|
||||
import dbus.mainloop.glib
|
||||
import dbusmock
|
||||
import os
|
||||
import time
|
||||
from output_checker import OutputChecker
|
||||
|
||||
import os
|
||||
import time
|
||||
try:
|
||||
import dbusmock
|
||||
import dbus
|
||||
import dbus.mainloop.glib
|
||||
except Exception as e:
|
||||
print("Missing dependencies: %s" % str(e))
|
||||
sys.exit(1 if os.getenv('REQUIRE_TESTS') else 77)
|
||||
|
||||
VALID_FINGER_NAMES = [
|
||||
'left-thumb',
|
||||
|
|
@ -50,7 +56,7 @@ class TestFprintdUtilsBase(dbusmock.DBusTestCase):
|
|||
template_path = './'
|
||||
if 'TOPSRCDIR' in os.environ:
|
||||
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
||||
klass.template_name = template_path + 'dbusmock/fprintd.py'
|
||||
klass.template_name = template_path + 'dbusmock-services/fprintd.py'
|
||||
print ('Using template from %s' % klass.template_name)
|
||||
|
||||
klass.tools_prefix = ''
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue