From b1fbbde0b097496b5113b50124b31f56fd4f76bb Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 8 Jul 2019 21:21:17 +0300 Subject: [PATCH] Use pytest parallelisation if available. --- .travis.yml | 2 +- run_project_tests.py | 2 ++ run_unittests.py | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a969307e0..8f393f158 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,4 +63,4 @@ script: /bin/sh -c "cd /root && mkdir -p tools; wget -c http://nirbheek.in/files/binaries/ninja/linux-amd64/ninja -O /root/tools/ninja; chmod +x /root/tools/ninja; CC=$CC CXX=$CXX OBJC=$CC OBJCXX=$CXX PATH=/root/tools:$PATH MESON_FIXED_NINJA=1 ./run_tests.py $RUN_TESTS_ARGS -- $MESON_ARGS && chmod -R a+rwX .coverage" fi # Ensure that llvm is added after $PATH, otherwise the clang from that llvm install will be used instead of the native apple clang. - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib OBJC=$CC OBJCXX=$CXX PATH=$HOME/tools:/usr/local/opt/qt/bin:$PATH:$(brew --prefix llvm)/bin MESON_FIXED_NINJA=1 ./run_tests.py --backend=ninja -- $MESON_ARGS ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then SDKROOT=$(xcodebuild -version -sdk macosx Path) CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib OBJC=$CC OBJCXX=$CXX PATH=$HOME/tools:/usr/local/opt/qt/bin:$PATH:$(brew --prefix llvm)/bin MESON_FIXED_NINJA=1 ./run_tests.py $RUN_TESTS_ARGS --backend=ninja -- $MESON_ARGS ; fi diff --git a/run_project_tests.py b/run_project_tests.py index d127e65f2..154da00af 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -803,6 +803,8 @@ def check_format(): for (root, _, files) in os.walk('.'): if '.dub' in root: # external deps are here continue + if '.pytest_cache' in root: + continue if 'meson-logs' in root or 'meson-private' in root: continue for fname in files: diff --git a/run_unittests.py b/run_unittests.py index d9281cfca..33174b191 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3398,7 +3398,7 @@ recommended as it is not supported on some platforms''') for entry in res: name = entry['name'] - self.assertEquals(entry['subproject'], expected[name]) + self.assertEqual(entry['subproject'], expected[name]) def test_introspect_projectinfo_subproject_dir(self): testdir = os.path.join(self.common_test_dir, '79 custom subproject dir') @@ -6480,6 +6480,17 @@ 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 + return subprocess.run(python_command + ['-m', 'pytest'] + pytest_args).returncode + except ImportError: + pass + # All attempts at locating pytest failed, fall back to plain unittest. cases = ['InternalTests', 'DataTests', 'AllPlatformTests', 'FailureTests', 'PythonTests', 'NativeFileTests', 'RewriterTests', 'CrossFileTests', 'TAPParserTests',