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 Aug 14, 2024
1 parent 45219c0 commit 0a4325c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,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 @@ -398,17 +399,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 auto
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 auto
# 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 auto
env:
TEST_CPPCHECK_INJECT_J: 2

Expand All @@ -417,7 +418,7 @@ jobs:
if: false
run: |
cd test/cli
python3 -m pytest -Werror --strict-markers -vv
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/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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 @@ -171,13 +172,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 @@ -186,7 +187,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 @@ -64,6 +64,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 @@ -99,13 +100,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 @@ -114,7 +115,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 @@ -86,6 +86,7 @@ jobs:
python -m pip install pylint
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 @@ -133,14 +134,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 @@ -64,6 +64,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 @@ -98,15 +99,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 @@ -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
7 changes: 4 additions & 3 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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 @@ -98,13 +99,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 @@ -113,7 +114,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 0a4325c

Please sign in to comment.