diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2019-07-20 11:40:45 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2019-07-20 07:39:18 +0000 |
commit | 4200afc74d1e6ba6d117e900799d0d82a85bae8a (patch) | |
tree | 04317f2c55dbcbfcb91eba130d5c9a97285ba2bd /run_unittests.py | |
parent | 81b6c9ef8c27404778abe749b87bf5d0a5707c82 (diff) | |
download | meson-4200afc74d1e6ba6d117e900799d0d82a85bae8a.zip meson-4200afc74d1e6ba6d117e900799d0d82a85bae8a.tar.gz meson-4200afc74d1e6ba6d117e900799d0d82a85bae8a.tar.bz2 |
unit tests: Check whether pytest-xdist is available
Also, always run pytest using the module format to ensure that we're
always using the Python interpreter selected by the user.
Fixes issue reported in https://github.com/mesonbuild/meson/pull/5621#issuecomment-513034198
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/run_unittests.py b/run_unittests.py index 0bb532a..c83444c 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -6599,15 +6599,14 @@ def unset_envs(): def main(): unset_envs() - pytest_args = ['-n', 'auto', './run_unittests.py'] - if shutil.which('pytest-3'): - return subprocess.run(['pytest-3'] + pytest_args).returncode - elif shutil.which('pytest'): - return subprocess.run(['pytest'] + pytest_args).returncode try: import pytest # noqa: F401 + # Need pytest-xdist for `-n` arg + import xdist # noqa: F401 + pytest_args = ['-n', 'auto', './run_unittests.py'] return subprocess.run(python_command + ['-m', 'pytest'] + pytest_args).returncode except ImportError: + print('pytest-xdist not found, using unittest instead') pass # All attempts at locating pytest failed, fall back to plain unittest. cases = ['InternalTests', 'DataTests', 'AllPlatformTests', 'FailureTests', |