Skip to content

Commit c6362d0

Browse files
CI: install pytest-xdist; fix cross-drive Windows failure in new tests
pytest-xdist was never installed by tests.yml on any platform, so every test in test_xdist.py (importorskip("xdist")) -- including the new test_xdist_fail_under_uses_merged_coverage -- was silently skipped in CI, on every run. Add it alongside pytest in the cross-platform install step (test_xdist.py already self-skips on Windows via its own pytestmark, so this activates it for Linux/macOS). Also fixes a real Windows CI failure this surfaced in the sibling test_fail_under_precedence_with_failing_pytest_run: GitHub Actions Windows runners check the repo out to D:\, while tmp_path resolves under C:\Users\...\Temp. Passing an absolute C:\ file to `-m pytest` while cwd sat on D:\ made pytest's rootdir/common-ancestor computation fall back to scanning a drive root, hitting the classic "C:\Documents and Settings" permission-denied junction. Fixed by running the inner subprocess with cwd=tmp_path and a relative filename instead, which also lets the now-unnecessary --source argument be dropped (default cwd-relative file matching covers it). Applied the same pattern to test_xdist_fail_under_uses_merged_coverage for consistency, now that it actually runs in CI. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 7c34555 commit c6362d0

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: install prereqs
4848
run: |
4949
python3 -m pip install -U pip # to avoid warnings
50-
python3 -m pip install pytest
50+
python3 -m pip install pytest pytest-xdist
5151
5252
- name: install Unix dependencies
5353
if: matrix.os != 'windows-latest'

tests/test_coverage.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,12 +757,16 @@ def test_fail():
757757
"""))
758758

759759
# coverage is fine -- pytest's own failure exit code (1) must be preserved
760-
p = subprocess.run(f"{sys.executable} -m slipcover --source {tmp_path} --fail-under 1 -m pytest {test_file}".split(), check=False)
760+
p = subprocess.run(
761+
[sys.executable, '-m', 'slipcover', '--fail-under', '1', '-m', 'pytest', test_file.name],
762+
cwd=str(tmp_path), check=False)
761763
assert 1 == p.returncode
762764

763765
# coverage is below threshold -- fail-under (2) must override pytest's
764766
# own exit code
765-
p = subprocess.run(f"{sys.executable} -m slipcover --source {tmp_path} --fail-under 100 -m pytest {test_file}".split(), check=False)
767+
p = subprocess.run(
768+
[sys.executable, '-m', 'slipcover', '--fail-under', '100', '-m', 'pytest', test_file.name],
769+
cwd=str(tmp_path), check=False)
766770
assert 2 == p.returncode
767771

768772

tests/test_xdist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ def test_bar():
248248
# real merged coverage is 10/12 = 83.3% (the "return 1"/"return 3"
249249
# branches are never taken) -- comfortably above 50, so this must pass.
250250
# The coordinator's own local, unmerged view would incorrectly see 0%
251-
# (it discovers the file via --source but never executes it itself,
251+
# (it discovers the file via cwd-matching but never executes it itself,
252252
# since actual test execution happens only in the xdist workers), which
253253
# would incorrectly fail this same check.
254254
result = subprocess.run(
255-
[sys.executable, '-m', 'slipcover', '--source', str(tmp_path),
256-
'--fail-under', '50',
257-
'-m', 'pytest', '-n', '2', str(test_file)],
255+
[sys.executable, '-m', 'slipcover', '--fail-under', '50',
256+
'-m', 'pytest', '-n', '2', test_file.name],
257+
cwd=str(tmp_path),
258258
capture_output=True,
259259
text=True
260260
)

0 commit comments

Comments
 (0)