aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-01-31 19:10:37 -0500
committerNirbheek Chauhan <nirbheek@centricular.com>2022-02-14 15:49:21 +0530
commit84ac38c1edbbe0074337e844e70b34429d06a50b (patch)
tree7cc9eb2da35f023b767abef542067da7b7f0e1f0
parentb8c3d2e6348f079afc922edd96f6dda54c61a3d9 (diff)
downloadmeson-84ac38c1edbbe0074337e844e70b34429d06a50b.zip
meson-84ac38c1edbbe0074337e844e70b34429d06a50b.tar.gz
meson-84ac38c1edbbe0074337e844e70b34429d06a50b.tar.bz2
run_unittests: check for pytest and pytest-xdist separately
Do not quit from using pytest at all, when pytest is present, simply because xdist isn't available. Even without xdist, pytest is still useful. There doesn't seem to be any particular reason to require xdist. It just happens to have been implemented that way, back in commit 4200afc74d1e6ba6d117e900799d0d82a85bae8a when we originally added a check to avoid pytest erroring out with unknown options when xdist options are passed and xdist is not installed.
-rwxr-xr-xrun_unittests.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/run_unittests.py b/run_unittests.py
index ad62823..ddcde76 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -122,13 +122,16 @@ def main():
try:
import pytest # noqa: F401
- # Need pytest-xdist for `-n` arg
- import xdist # noqa: F401
pytest_args = []
- # Don't use pytest-xdist when running single unit tests since it wastes
- # time spawning a lot of processes to distribute tests to in that case.
- if not running_single_tests(sys.argv, cases):
- pytest_args += ['-n', 'auto']
+ try:
+ # Need pytest-xdist for `-n` arg
+ import xdist # noqa: F401
+ # Don't use pytest-xdist when running single unit tests since it wastes
+ # time spawning a lot of processes to distribute tests to in that case.
+ if not running_single_tests(sys.argv, cases):
+ pytest_args += ['-n', 'auto']
+ except ImportError:
+ print('pytest-xdist not found, tests will not be distributed across CPU cores')
# Let there be colors!
if 'CI' in os.environ:
pytest_args += ['--color=yes']
@@ -143,7 +146,7 @@ def main():
pass
return subprocess.run(python_command + ['-m', 'pytest'] + pytest_args).returncode
except ImportError:
- print('pytest-xdist not found, using unittest instead')
+ print('pytest not found, using unittest instead')
# Fallback to plain unittest.
return unittest.main(defaultTest=cases, buffer=True)