diff --git a/test/conftest.py b/test/conftest.py new file mode 100644 index 0000000..85f1c9f --- /dev/null +++ b/test/conftest.py @@ -0,0 +1,11 @@ +import os + +try: + import xdist # noqa: F401 + + # Otherwise we get unknown hook 'pytest_xdist_auto_num_workers' + def pytest_xdist_auto_num_workers(config): + return os.getenv("FDO_CI_CONCURRENT", None) + +except ImportError: + pass diff --git a/test/meson.build b/test/meson.build index d9c56d9..f1a9285 100644 --- a/test/meson.build +++ b/test/meson.build @@ -44,6 +44,13 @@ if build_oeffis endif pymod.find_installation('python3', modules: required_python_modules) pytest = find_program('pytest-3', 'pytest') +pytest_args = ['--verbose', '--log-level=DEBUG'] + +optional_python_modules = ['xdist'] +if pymod.find_installation('python3', modules: optional_python_modules, required: false).found() + pytest_args += ['-n', 'auto'] + configure_file(input: 'conftest.py', output: '@PLAINNAME@', copy: true) +endif if build_oeffis test('unit-tests-oeffis', @@ -57,7 +64,7 @@ if build_oeffis env = environment() env.set('LD_LIBRARY_PATH', meson.project_build_root()) test('oeffis-pytest', pytest, - args: ['--verbose', '--log-level=DEBUG'], + args: pytest_args, suite: 'python', workdir: meson.current_source_dir(), env: env, @@ -132,7 +139,7 @@ configure_file(input: 'test_protocol.py', configuration: protocol_test_config) test('protocol-test', pytest, - args: ['--verbose', '--log-level=DEBUG'], + args: pytest_args, suite: 'python', workdir: meson.project_build_root(), ) @@ -140,7 +147,7 @@ if valgrind.found() env = environment() env.set('LIBEI_USE_VALGRIND', '1') test('protocol-test-valgrind', pytest, - args: ['--verbose', '--log-level=DEBUG'], + args: pytest_args, suite: 'python', workdir: meson.project_build_root(), env: env