mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-20 12:40:06 +01:00
A lot of the protocol tests have enforced timeouts because we need to wait for the server to do something (or not). Running the protocol tests with xdist means we can run those in parallel, which on my local box roughly halves the time required to run all protocol tests. Of course, this is all terrible. The only way to tell pytest to use xdist is with `pytest -n <jobcount>`. But -n is only available if xdist is installed. Dynamically adding commandline options is supposed to be possible with `pytest_load_initial_conftests` in conftest.py, but that doesn't actually work unless we're configuring a setuptool plugin. Which we don't. What would work is `pytest_cmdline_preparse` but that has been deprecated. So we work around this by having meson check if xdist is available and append `-n auto` for us. In the CI let's be nice and only use the FDI_CI_CONCURRENT number of jobs rather than hogging everything available. And, continuation from "all is terrible": pytest complains if you have a hook that's unknown. So if xdist is not available, you must not have the hook in conftest.py. Which means we have to do it within an import + ImportError clause. But yay, now we're saving literally seconds!
11 lines
245 B
Python
11 lines
245 B
Python
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
|