mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-14 10:38:08 +02:00
build: Make tests optional
And check for dbusmock and gi being available. Closes: #95
This commit is contained in:
parent
915f3dfc92
commit
b0f6aa5e85
2 changed files with 20 additions and 1 deletions
17
meson.build
17
meson.build
|
|
@ -62,7 +62,22 @@ if get_option('gtk_doc')
|
|||
subdir('docs')
|
||||
endif
|
||||
|
||||
subdir('tests')
|
||||
if get_option('tests')
|
||||
# Python 3 required modules
|
||||
python3_required_modules = ['dbusmock', 'gi']
|
||||
|
||||
python = import('python')
|
||||
python3 = python.find_installation('python3')
|
||||
foreach p : python3_required_modules
|
||||
# Source: https://docs.python.org/3/library/importlib.html#checking-if-a-module-can-be-imported
|
||||
script = 'import importlib.util; import sys; exit(1) if importlib.util.find_spec(\''+ p +'\') is None else exit(0)'
|
||||
if run_command(python3, '-c', script, check: false).returncode() != 0
|
||||
error('Python3 module \'' + p + '\' required for running tests but not found')
|
||||
endif
|
||||
endforeach
|
||||
|
||||
subdir('tests')
|
||||
endif
|
||||
|
||||
meson.add_dist_script(
|
||||
find_program('check-news.sh').path(),
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ option('pylint',
|
|||
type: 'boolean',
|
||||
value: false,
|
||||
description: 'Run pylint checks, for developers only')
|
||||
option('tests',
|
||||
description: 'Whether to run tests',
|
||||
type: 'boolean',
|
||||
value: false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue