Skip to content

Commit eea976a

Browse files
EliahKaganclaude
andcommitted
Add jobs to reproduce Cygwin safe.directory submodule issue
Remove the Cygwin xfail decorations from test_submodules in test_docs.py and test_repo.py, and from test_root_module in test_submodule.py, so the tests surface the underlying failure directly. Add 30 reproduce-safe-dir matrix jobs to cygwin-test.yml. Each runs the three submodule tests under the current safe.directory configuration, which covers the main repo but not submodule working trees. Expected result: all jobs fail. Most should fail with ValueError (git cat-file exits due to dubious ownership, Python reads empty stdout). A few may fail with IndexError (git cat-file exits before Python writes to stdin, raising BrokenPipeError, which is IOError, which iter_items catches — producing an empty submodule list). The existing test job's env, defaults, and setup steps gain YAML anchors so the new job can reference them without duplication. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a294a6 commit eea976a

4 files changed

Lines changed: 53 additions & 30 deletions

File tree

.github/workflows/cygwin-test.yml

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,63 +20,73 @@ jobs:
2020

2121
runs-on: windows-latest
2222

23-
env:
23+
env: &cygwin-env
2424
CHERE_INVOKING: "1"
2525
CYGWIN_NOWINPATH: "1"
2626

27-
defaults:
27+
defaults: &cygwin-defaults
2828
run:
2929
shell: C:\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr "{0}"
3030

3131
steps:
32-
- name: Force LF line endings
32+
- &force-lf
33+
name: Force LF line endings
3334
run: |
3435
git config --global core.autocrlf false # Affects the non-Cygwin git.
3536
shell: pwsh # Do this outside Cygwin, to affect actions/checkout.
3637

37-
- uses: actions/checkout@v6
38+
- &checkout
39+
uses: actions/checkout@v6
3840
with:
3941
fetch-depth: 0
4042

41-
- name: Install Cygwin
43+
- &install-cygwin
44+
name: Install Cygwin
4245
uses: cygwin/cygwin-install-action@v6
4346
with:
4447
packages: git python39 python-pip-wheel python-setuptools-wheel python-wheel-wheel
4548
add-to-path: false # No need to change $PATH outside the Cygwin environment.
4649

47-
- name: Arrange for verbose output
50+
- &verbose-output
51+
name: Arrange for verbose output
4852
run: |
4953
# Arrange for verbose output but without shell environment setup details.
5054
echo 'set -x' >~/.bash_profile
5155
52-
- name: Special configuration for Cygwin git
56+
- &safe-directory
57+
name: Special configuration for Cygwin git
5358
run: |
5459
git config --global --add safe.directory "$(pwd)"
5560
git config --global --add safe.directory "$(pwd)/.git"
5661
git config --global core.autocrlf false
5762
58-
- name: Prepare this repo for tests
63+
- &prepare-repo
64+
name: Prepare this repo for tests
5965
run: |
6066
./init-tests-after-clone.sh
6167
62-
- name: Set git user identity and command aliases for the tests
68+
- &git-identity
69+
name: Set git user identity and command aliases for the tests
6370
run: |
6471
git config --global user.email "travis@ci.com"
6572
git config --global user.name "Travis Runner"
6673
# If we rewrite the user's config by accident, we will mess it up
6774
# and cause subsequent tests to fail
6875
cat test/fixtures/.gitconfig >> ~/.gitconfig
6976
70-
- name: Set up virtual environment
77+
- &setup-venv
78+
name: Set up virtual environment
7179
run: |
7280
python3.9 -m venv .venv
7381
echo 'BASH_ENV=.venv/bin/activate' >>"$GITHUB_ENV"
7482
75-
- name: Update PyPA packages
83+
- &update-pypa
84+
name: Update PyPA packages
7685
run: |
7786
python -m pip install -U pip 'setuptools; python_version<"3.12"' wheel
7887
79-
- name: Install project and test dependencies
88+
- &install-deps
89+
name: Install project and test dependencies
8090
run: |
8191
pip install '.[test]'
8292
@@ -91,3 +101,34 @@ jobs:
91101
- name: Test with pytest (${{ matrix.additional-pytest-args }})
92102
run: |
93103
pytest --color=yes -p no:sugar --instafail -vv ${{ matrix.additional-pytest-args }}
104+
105+
reproduce-safe-dir:
106+
strategy:
107+
matrix:
108+
run: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
109+
fail-fast: false
110+
111+
runs-on: windows-latest
112+
113+
env: *cygwin-env
114+
115+
defaults: *cygwin-defaults
116+
117+
steps:
118+
- *force-lf
119+
- *checkout
120+
- *install-cygwin
121+
- *verbose-output
122+
- *safe-directory
123+
- *prepare-repo
124+
- *git-identity
125+
- *setup-venv
126+
- *update-pypa
127+
- *install-deps
128+
129+
- name: Run submodule tests
130+
run: |
131+
python -m pytest -vv \
132+
test/test_docs.py::Tutorials::test_submodules \
133+
test/test_repo.py::TestRepo::test_submodules \
134+
test/test_submodule.py::TestSubmodule::test_root_module

test/test_docs.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import gc
77
import os
88
import os.path
9-
import sys
10-
11-
import pytest
129

1310
from test.lib import TestBase
1411
from test.lib.helper import with_rw_directory
@@ -478,11 +475,6 @@ def test_references_and_objects(self, rw_dir):
478475

479476
repo.git.clear_cache()
480477

481-
@pytest.mark.xfail(
482-
sys.platform == "cygwin",
483-
reason="Cygwin GitPython can't find SHA for submodule",
484-
raises=ValueError,
485-
)
486478
def test_submodules(self):
487479
# [1-test_submodules]
488480
repo = self.rorepo

test/test_repo.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -877,11 +877,6 @@ def test_repo_odbtype(self):
877877
target_type = GitCmdObjectDB
878878
self.assertIsInstance(self.rorepo.odb, target_type)
879879

880-
@pytest.mark.xfail(
881-
sys.platform == "cygwin",
882-
reason="Cygwin GitPython can't find submodule SHA",
883-
raises=ValueError,
884-
)
885880
def test_submodules(self):
886881
self.assertEqual(len(self.rorepo.submodules), 1) # non-recursive
887882
self.assertGreaterEqual(len(list(self.rorepo.iter_submodules())), 2)

test/test_submodule.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,6 @@ def test_base_rw(self, rwrepo):
480480
def test_base_bare(self, rwrepo):
481481
self._do_base_tests(rwrepo)
482482

483-
@pytest.mark.xfail(
484-
sys.platform == "cygwin",
485-
reason="Cygwin GitPython can't find submodule SHA",
486-
raises=ValueError,
487-
)
488483
@pytest.mark.xfail(
489484
HIDE_WINDOWS_KNOWN_ERRORS,
490485
reason=(

0 commit comments

Comments
 (0)