Skip to content

Commit b2ccf23

Browse files
akxhugovk
andcommitted
CI: Run tests in parallel with pytest-xdist
Pass the options at each call site rather than putting them in addopts, so pytests may also run without test-xdist. REVERSE dropped because xdist runs tests in arbitrary order anyhow. That matrix entry still does PYTHONOPTIMIZE=1. Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 7849bd5 commit b2ccf23

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

.ci/test.cmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
python.exe -c "from PIL import Image"
22
IF ERRORLEVEL 1 EXIT /B
3-
python.exe -bb -m pytest -vv -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests
3+
python.exe -bb -m pytest -vv -x -W always Tests -m "isolated"
4+
IF ERRORLEVEL 1 EXIT /B
5+
python.exe -bb -m pytest -vv -x -W always Tests -m "not isolated" --numprocesses=logical --dist=worksteal --cov PIL --cov Tests --cov-report term --cov-report xml

.ci/test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ set -e
44

55
python3 -c "from PIL import Image"
66

7-
python3 -bb -m pytest -vv -x -W always --cov PIL --cov Tests --cov-report term --cov-report xml Tests $REVERSE
7+
python3 -bb -m pytest -vv -x -W always Tests -m "isolated"
8+
python3 -bb -m pytest -vv -x -W always Tests -m "not isolated" \
9+
--numprocesses=logical --dist=worksteal \
10+
--cov PIL --cov Tests --cov-report term --cov-report xml

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
"3.11",
4747
]
4848
include:
49-
- { python-version: "3.13", PYTHONOPTIMIZE: 1, REVERSE: "--reverse" }
49+
- { python-version: "3.13", PYTHONOPTIMIZE: 1 }
5050
- { python-version: "3.12", PYTHONOPTIMIZE: 2 }
5151
# Intel
5252
- { os: "macos-26-intel", python-version: "3.11" }
@@ -125,9 +125,6 @@ jobs:
125125
126126
- name: Test
127127
run: |
128-
if [ $REVERSE ]; then
129-
python3 -m pip install pytest-reverse
130-
fi
131128
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
132129
xvfb-run -s '-screen 0 1024x768x24' sway&
133130
export WAYLAND_DISPLAY=wayland-1
@@ -137,7 +134,6 @@ jobs:
137134
fi
138135
env:
139136
PYTHONOPTIMIZE: ${{ matrix.PYTHONOPTIMIZE }}
140-
REVERSE: ${{ matrix.REVERSE }}
141137

142138
- name: Prepare to upload errors
143139
if: failure()

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ test:
9797

9898
.PHONY: test-p
9999
test-p:
100-
python3 -c "import xdist" > /dev/null 2>&1 || python3 -m pip install pytest-xdist
101-
python3 -m pytest -qq -n auto
102-
100+
python3 -c "import xdist" > /dev/null 2>&1 || python3 -m pip install pytest-xdist psutil
101+
python3 -m pytest -qq -m "isolated"
102+
python3 -m pytest -qq -m "not isolated" --numprocesses=logical --dist=worksteal
103103

104104
.PHONY: valgrind
105105
valgrind:

0 commit comments

Comments
 (0)