Skip to content

Commit

Permalink
use pytest-xdist to utilize multiple workers for Python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Oct 28, 2024
1 parent 55951dd commit 0f81446
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-13]
include:
- xdist_n: auto
# FIXME: test_color_tty fails with xdist
- os: macos-13
xdist_n: '1'
fail-fast: false # Prefer quick result

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -376,6 +381,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil
- name: Build cppcheck
Expand All @@ -401,17 +407,17 @@ jobs:
- name: Run test/cli
run: |
cd test/cli
python3 -m pytest -Werror --strict-markers -vv
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }}
cd ../../..
ln -s cppcheck 'cpp check'
cd 'cpp check/test/cli'
python3 -m pytest -Werror --strict-markers -vv
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }}
# do not use pushd in this step since we go below the working directory
- name: Run test/cli (-j2)
run: |
cd test/cli
python3 -m pytest -Werror --strict-markers -vv
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }}
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -420,7 +426,7 @@ jobs:
if: false
run: |
cd test/cli
python3 -m pytest -Werror --strict-markers -vv
python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }}
env:
TEST_CPPCHECK_INJECT_CLANG: clang

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ jobs:
python -m pip install pytest || exit /b !errorlevel!
python -m pip install pytest-custom_exit_code || exit /b !errorlevel!
python -m pip install pytest-timeout || exit /b !errorlevel!
python -m pip install pytest-xdist || exit /b !errorlevel!
python -m pip install psutil || exit /b !errorlevel!
- name: Run CMake
Expand Down Expand Up @@ -181,13 +182,13 @@ jobs:
if: matrix.config == 'release'
run: |
cd test/cli || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv -n auto || exit /b !errorlevel!
- name: Run test/cli (-j2)
if: matrix.config == 'release'
run: |
cd test/cli || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv -n auto || exit /b !errorlevel!
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -196,7 +197,7 @@ jobs:
if: false # matrix.config == 'release'
run: |
cd test/cli || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv || exit /b !errorlevel!
python -m pytest -Werror --strict-markers -vv -n auto || exit /b !errorlevel!
env:
TEST_CPPCHECK_INJECT_CLANG: clang

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil
# TODO: disable all warnings
Expand Down Expand Up @@ -101,13 +102,13 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
- name: Run test/cli (-j2)
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -116,7 +117,7 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_CLANG: clang

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/scriptcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
python -m pip install 'pylint<=3.3.0'
python -m pip install unittest2
python -m pip install pytest
python -m pip install pytest-xdist
python -m pip install pygments
python -m pip install requests
python -m pip install psutil
Expand Down Expand Up @@ -134,14 +135,14 @@ jobs:
- name: test addons
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
run: |
python -m pytest --strict-markers -vv addons/test
python -m pytest --strict-markers -vv -n auto addons/test
env:
PYTHONPATH: ./addons

- name: test addons
if: matrix.python-version != '3.9' && matrix.python-version != '3.10'
run: |
python -m pytest -Werror --strict-markers -vv addons/test
python -m pytest -Werror --strict-markers -vv -n auto addons/test
env:
PYTHONPATH: ./addons

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil
- name: CMake
Expand Down Expand Up @@ -100,15 +101,15 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_EXECUTOR: thread

- name: Run test/cli (-j2)
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -117,7 +118,7 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_CLANG: clang

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
python3 -m pip install pytest-xdist
python3 -m pip install psutil
# TODO: disable warnings
Expand Down Expand Up @@ -100,13 +101,13 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
- name: Run test/cli (-j2)
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -115,7 +116,7 @@ jobs:
run: |
pwd=$(pwd)
cd test/cli
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv
TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto
env:
TEST_CPPCHECK_INJECT_CLANG: clang

Expand Down

0 comments on commit 0f81446

Please sign in to comment.