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 Sep 17, 2024
1 parent c3b9131 commit 86e84ad
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 @@ -374,6 +374,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 @@ -399,17 +400,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 @@ -418,7 +419,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 @@ -133,6 +133,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 @@ -172,13 +173,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 @@ -187,7 +188,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 @@ -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 all 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
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
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 @@ -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
- name: CMake
Expand Down Expand Up @@ -99,15 +100,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 @@ -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
7 changes: 4 additions & 3 deletions .github/workflows/ubsan.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 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

0 comments on commit 86e84ad

Please sign in to comment.