mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2025-12-25 01:20:08 +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
|
stage: build
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
script:
|
script:
|
||||||
- meson _build
|
- meson _build -Drequire_tests=true
|
||||||
- ninja -C _build -v
|
- ninja -C _build -v
|
||||||
- ninja -C _build -v install
|
- ninja -C _build -v install
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ build_dev:
|
||||||
- .install_libfprint_dev
|
- .install_libfprint_dev
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- meson _build --werror -Dgtk_doc=true
|
- meson _build -Drequire_tests=true --werror -Dgtk_doc=true
|
||||||
- ninja -C _build -v
|
- ninja -C _build -v
|
||||||
- ninja -C _build -v install
|
- ninja -C _build -v install
|
||||||
artifacts:
|
artifacts:
|
||||||
|
|
@ -92,7 +92,7 @@ test_dev:
|
||||||
- .install_libfprint_dev
|
- .install_libfprint_dev
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
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
|
- meson test -C _build --print-errorlogs --no-stdsplit --timeout-multiplier 3
|
||||||
- ninja -C _build coverage
|
- ninja -C _build coverage
|
||||||
- cat _build/meson-logs/coverage.txt
|
- cat _build/meson-logs/coverage.txt
|
||||||
|
|
@ -109,7 +109,7 @@ test_dev_with_sanitizer:
|
||||||
- .install_libfprint_dev
|
- .install_libfprint_dev
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
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
|
- meson test -C _build --print-errorlogs --no-stdsplit --timeout-multiplier 5
|
||||||
artifacts:
|
artifacts:
|
||||||
name: meson-logs
|
name: meson-logs
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,11 @@ python3_available_modules = []
|
||||||
|
|
||||||
foreach module, required : python3_test_modules
|
foreach module, required : python3_test_modules
|
||||||
if required and run_command(python3, '-c', 'import @0@'.format(module)).returncode() != 0
|
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
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,8 @@ option('gtk_doc',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
value: false,
|
value: false,
|
||||||
description: 'Use gtk-doc to build documentation')
|
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 shutil
|
||||||
import socket
|
import socket
|
||||||
import struct
|
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
|
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:
|
try:
|
||||||
from subprocess import DEVNULL
|
from subprocess import DEVNULL
|
||||||
|
|
@ -326,7 +330,7 @@ class FPrintdTest(dbusmock.DBusTestCase):
|
||||||
if 'POLKITD_MOCK_PATH' in os.environ:
|
if 'POLKITD_MOCK_PATH' in os.environ:
|
||||||
polkitd_template = os.path.join(os.getenv('POLKITD_MOCK_PATH'), 'polkitd.py')
|
polkitd_template = os.path.join(os.getenv('POLKITD_MOCK_PATH'), 'polkitd.py')
|
||||||
else:
|
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)
|
print ('Using template from %s' % polkitd_template)
|
||||||
|
|
||||||
self._polkitd, self._polkitd_obj = self.spawn_server_template(
|
self._polkitd, self._polkitd_obj = self.spawn_server_template(
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ foreach pt: python_tests
|
||||||
suite: ut_suite,
|
suite: ut_suite,
|
||||||
depends: pt.get('depends', []),
|
depends: pt.get('depends', []),
|
||||||
workdir: pt.get('workdir', meson.build_root()),
|
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),
|
timeout: pt.get('timeout', 30),
|
||||||
is_parallel: pt.get('is_parallel', true),
|
is_parallel: pt.get('is_parallel', true),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,17 @@ import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import dbus
|
|
||||||
import dbusmock
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
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_SUCCESS = 0
|
||||||
PAM_AUTH_ERR = 7
|
PAM_AUTH_ERR = 7
|
||||||
|
|
@ -62,7 +66,7 @@ class TestPamFprintd(dbusmock.DBusTestCase):
|
||||||
template_path = './'
|
template_path = './'
|
||||||
if 'TOPSRCDIR' in os.environ:
|
if 'TOPSRCDIR' in os.environ:
|
||||||
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
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)
|
print ('Using template from %s' % klass.template_name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,19 @@ import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import dbus
|
|
||||||
import dbus.mainloop.glib
|
|
||||||
import dbusmock
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from output_checker import OutputChecker
|
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 = [
|
VALID_FINGER_NAMES = [
|
||||||
'left-thumb',
|
'left-thumb',
|
||||||
|
|
@ -50,7 +56,7 @@ class TestFprintdUtilsBase(dbusmock.DBusTestCase):
|
||||||
template_path = './'
|
template_path = './'
|
||||||
if 'TOPSRCDIR' in os.environ:
|
if 'TOPSRCDIR' in os.environ:
|
||||||
template_path = os.environ['TOPSRCDIR'] + '/tests/'
|
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)
|
print ('Using template from %s' % klass.template_name)
|
||||||
|
|
||||||
klass.tools_prefix = ''
|
klass.tools_prefix = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue