Skip to content

Commit 58076c2

Browse files
authored
Merge pull request #1679 from EliahKagan/verbose-ci
Make clear every test's status in every CI run
2 parents abd445f + 4860f70 commit 58076c2

13 files changed

+119
-130
lines changed

.github/workflows/cygwin-test.yml

+27-17
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ on: [push, pull_request, workflow_dispatch]
55
jobs:
66
build:
77
runs-on: windows-latest
8+
89
strategy:
910
fail-fast: false
11+
1012
env:
1113
CHERE_INVOKING: 1
12-
SHELLOPTS: igncr
1314
TMP: "/tmp"
1415
TEMP: "/tmp"
16+
1517
defaults:
1618
run:
17-
shell: bash.exe --noprofile --norc -exo pipefail -o igncr "{0}"
19+
shell: C:\cygwin\bin\bash.exe --noprofile --norc -exo pipefail -o igncr "{0}"
1820

1921
steps:
2022
- name: Force LF line endings
21-
run: git config --global core.autocrlf input
23+
run: |
24+
git config --global core.autocrlf false # Affects the non-Cygwin git.
25+
shell: bash
2226

2327
- uses: actions/checkout@v4
2428
with:
@@ -29,36 +33,42 @@ jobs:
2933
with:
3034
packages: python39 python39-pip python39-virtualenv git
3135

32-
- name: Show python and git versions
36+
- name: Special configuration for Cygwin's git
3337
run: |
34-
/usr/bin/python --version
35-
/usr/bin/git version
36-
37-
- name: Tell git to trust this repo
38-
run: |
39-
/usr/bin/git config --global --add safe.directory "$(pwd)"
38+
git config --global --add safe.directory "$(pwd)"
39+
git config --global core.autocrlf false
4040
4141
- name: Prepare this repo for tests
4242
run: |
4343
TRAVIS=yes ./init-tests-after-clone.sh
4444
45-
- name: Further prepare git configuration for tests
45+
- name: Set git user identity and command aliases for the tests
4646
run: |
47-
/usr/bin/git config --global user.email "travis@ci.com"
48-
/usr/bin/git config --global user.name "Travis Runner"
47+
git config --global user.email "travis@ci.com"
48+
git config --global user.name "Travis Runner"
4949
# If we rewrite the user's config by accident, we will mess it up
5050
# and cause subsequent tests to fail
5151
cat test/fixtures/.gitconfig >> ~/.gitconfig
5252
5353
- name: Update PyPA packages
5454
run: |
55-
/usr/bin/python -m pip install --upgrade pip setuptools wheel
55+
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
56+
python -m pip install -U pip $(pip freeze --all | grep -oF setuptools) wheel
5657
5758
- name: Install project and test dependencies
5859
run: |
59-
/usr/bin/python -m pip install ".[test]"
60+
python -m pip install ".[test]"
61+
62+
- name: Show version and platform information
63+
run: |
64+
uname -a
65+
command -v git python
66+
git version
67+
python --version
68+
python -c 'import sys; print(sys.platform)'
69+
python -c 'import os; print(os.name)'
70+
python -c 'import git; print(git.compat.is_win)'
6071
6172
- name: Test with pytest
6273
run: |
63-
set +x
64-
/usr/bin/python -m pytest
74+
python -m pytest --color=yes -p no:sugar --instafail -vv

.github/workflows/lint.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v4
11-
- uses: actions/setup-python@v4
12-
with:
13-
python-version: "3.x"
14-
- uses: pre-commit/action@v3.0.0
10+
- uses: actions/checkout@v4
11+
12+
- uses: actions/setup-python@v4
13+
with:
14+
python-version: "3.x"
15+
16+
- uses: pre-commit/action@v3.0.0

.github/workflows/pythonpackage.yml

+16-14
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ permissions:
1010

1111
jobs:
1212
build:
13-
1413
runs-on: ubuntu-latest
14+
1515
strategy:
1616
fail-fast: false
1717
matrix:
@@ -20,6 +20,7 @@ jobs:
2020
- experimental: false
2121
- python-version: "3.12"
2222
experimental: true
23+
2324
defaults:
2425
run:
2526
shell: /bin/bash --noprofile --norc -exo pipefail {0}
@@ -36,16 +37,11 @@ jobs:
3637
python-version: ${{ matrix.python-version }}
3738
allow-prereleases: ${{ matrix.experimental }}
3839

39-
- name: Show python and git versions
40-
run: |
41-
python --version
42-
git version
43-
4440
- name: Prepare this repo for tests
4541
run: |
4642
TRAVIS=yes ./init-tests-after-clone.sh
4743
48-
- name: Prepare git configuration for tests
44+
- name: Set git user identity and command aliases for the tests
4945
run: |
5046
git config --global user.email "travis@ci.com"
5147
git config --global user.name "Travis Runner"
@@ -55,17 +51,23 @@ jobs:
5551
5652
- name: Update PyPA packages
5753
run: |
58-
python -m pip install --upgrade pip
59-
if pip freeze --all | grep --quiet '^setuptools=='; then
60-
# Python prior to 3.12 ships setuptools. Upgrade it if present.
61-
python -m pip install --upgrade setuptools
62-
fi
63-
python -m pip install --upgrade wheel
54+
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
55+
python -m pip install -U pip $(pip freeze --all | grep -oF setuptools) wheel
6456
6557
- name: Install project and test dependencies
6658
run: |
6759
pip install ".[test]"
6860
61+
- name: Show version and platform information
62+
run: |
63+
uname -a
64+
command -v git python
65+
git version
66+
python --version
67+
python -c 'import sys; print(sys.platform)'
68+
python -c 'import os; print(os.name)'
69+
python -c 'import git; print(git.compat.is_win)'
70+
6971
- name: Check types with mypy
7072
run: |
7173
mypy -p git
@@ -75,7 +77,7 @@ jobs:
7577

7678
- name: Test with pytest
7779
run: |
78-
pytest
80+
pytest --color=yes -p no:sugar --instafail -vv
7981
continue-on-error: false
8082

8183
- name: Documentation

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[tool.pytest.ini_options]
66
python_files = 'test_*.py'
77
testpaths = 'test' # space separated list of paths from root e.g test tests doc/testing
8-
addopts = '--cov=git --cov-report=term --maxfail=10 --force-sugar --disable-warnings'
8+
addopts = '--cov=git --cov-report=term --disable-warnings'
99
filterwarnings = 'ignore::DeprecationWarning'
1010
# --cov coverage
1111
# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml

test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ mypy
55
pre-commit
66
pytest
77
pytest-cov
8+
pytest-instafail
89
pytest-sugar

test/test_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import sys
99
import tempfile
10-
from unittest import SkipTest, skipIf
10+
from unittest import skipIf
1111

1212
from git import Repo
1313
from git.objects import Blob, Tree, Commit, TagObject
@@ -126,7 +126,7 @@ def test_add_unicode(self, rw_repo):
126126
try:
127127
file_path.encode(sys.getfilesystemencoding())
128128
except UnicodeEncodeError as e:
129-
raise SkipTest("Environment doesn't support unicode filenames") from e
129+
raise RuntimeError("Environment doesn't support unicode filenames") from e
130130

131131
with open(file_path, "wb") as fp:
132132
fp.write(b"something")

test/test_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def test_includes_order(self):
100100
# values must be considered as soon as they get them
101101
assert r_config.get_value("diff", "tool") == "meld"
102102
try:
103+
# FIXME: Split this assertion out somehow and mark it xfail (or fix it).
103104
assert r_config.get_value("sec", "var1") == "value1_main"
104105
except AssertionError as e:
105106
raise SkipTest("Known failure -- included values are not in effect right away") from e

test/test_fun.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
33
from os import stat
44
import os.path as osp
5-
from unittest import SkipTest
65

76
from git import Git
87
from git.index import IndexFile
@@ -279,7 +278,7 @@ def test_linked_worktree_traversal(self, rw_dir):
279278
"""Check that we can identify a linked worktree based on a .git file"""
280279
git = Git(rw_dir)
281280
if git.version_info[:3] < (2, 5, 1):
282-
raise SkipTest("worktree feature unsupported")
281+
raise RuntimeError("worktree feature unsupported (test needs git 2.5.1 or later)")
283282

284283
rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
285284
branch = rw_master.create_head("aaaaaaaa")

test/test_index.py

+23-19
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
from io import BytesIO
99
import os
10+
import os.path as osp
11+
from pathlib import Path
1012
from stat import S_ISLNK, ST_MODE
11-
import tempfile
12-
from unittest import skipIf
1313
import shutil
14+
import tempfile
15+
16+
import pytest
1417

1518
from git import (
1619
IndexFile,
@@ -28,21 +31,26 @@
2831
from git.index.fun import hook_path
2932
from git.index.typ import BaseIndexEntry, IndexEntry
3033
from git.objects import Blob
31-
from test.lib import TestBase, fixture_path, fixture, with_rw_repo
32-
from test.lib import with_rw_directory
33-
from git.util import Actor, rmtree
34-
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, hex_to_bin
34+
from test.lib import TestBase, fixture, fixture_path, with_rw_directory, with_rw_repo
35+
from git.util import Actor, hex_to_bin, rmtree
3536
from gitdb.base import IStream
3637

37-
import os.path as osp
38-
from git.cmd import Git
38+
HOOKS_SHEBANG = "#!/usr/bin/env sh\n"
3939

40-
from pathlib import Path
4140

42-
HOOKS_SHEBANG = "#!/usr/bin/env sh\n"
41+
def _found_in(cmd, directory):
42+
"""Check if a command is resolved in a directory (without following symlinks)."""
43+
path = shutil.which(cmd)
44+
return path and Path(path).parent == Path(directory)
45+
4346

4447
is_win_without_bash = is_win and not shutil.which("bash.exe")
4548

49+
is_win_with_wsl_bash = is_win and _found_in(
50+
cmd="bash.exe",
51+
directory=Path(os.getenv("WINDIR")) / "System32",
52+
)
53+
4654

4755
def _make_hook(git_dir, name, content, make_exec=True):
4856
"""A helper to create a hook"""
@@ -422,14 +430,6 @@ def _count_existing(self, repo, files):
422430

423431
# END num existing helper
424432

425-
@skipIf(
426-
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
427-
"""FIXME: File "C:\\projects\\gitpython\\git\\test\\test_index.py", line 642, in test_index_mutation
428-
self.assertEqual(fd.read(), link_target)
429-
AssertionError: '!<symlink>\xff\xfe/\x00e\x00t\x00c\x00/\x00t\x00h\x00a\x00t\x00\x00\x00'
430-
!= '/etc/that'
431-
""",
432-
)
433433
@with_rw_repo("0.1.6")
434434
def test_index_mutation(self, rw_repo):
435435
index = rw_repo.index
@@ -910,7 +910,11 @@ def test_pre_commit_hook_fail(self, rw_repo):
910910
else:
911911
raise AssertionError("Should have caught a HookExecutionError")
912912

913-
@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "TODO: fix hooks execution on Windows: #703")
913+
@pytest.mark.xfail(
914+
is_win_without_bash or is_win_with_wsl_bash,
915+
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
916+
raises=AssertionError,
917+
)
914918
@with_rw_repo("HEAD", bare=True)
915919
def test_commit_msg_hook_success(self, rw_repo):
916920
commit_message = "commit default head by Frèderic Çaufl€"

test/test_repo.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import pickle
1414
import sys
1515
import tempfile
16-
from unittest import mock, skipIf, SkipTest, skip
16+
from unittest import mock, skip
1717

1818
import pytest
1919

@@ -41,10 +41,8 @@
4141
UnsafeProtocolError,
4242
)
4343
from git.repo.fun import touch
44-
from test.lib import TestBase, with_rw_repo, fixture
45-
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
46-
from test.lib import with_rw_directory
47-
from git.util import join_path_native, rmtree, rmfile, bin_to_hex
44+
from git.util import bin_to_hex, cygpath, join_path_native, rmfile, rmtree
45+
from test.lib import TestBase, fixture, with_rw_directory, with_rw_repo
4846

4947
import os.path as osp
5048

@@ -764,16 +762,6 @@ def test_blame_accepts_rev_opts(self, git):
764762
self.rorepo.blame("HEAD", "README.md", rev_opts=["-M", "-C", "-C"])
765763
git.assert_called_once_with(*expected_args, **boilerplate_kwargs)
766764

767-
@skipIf(
768-
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
769-
"""FIXME: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute
770-
raise GitCommandError(command, status, stderr_value, stdout_value)
771-
GitCommandError: Cmd('git') failed due to: exit code(128)
772-
cmdline: git add 1__��ava verb��ten 1_test _myfile 1_test_other_file
773-
1_��ava-----verb��ten
774-
stderr: 'fatal: pathspec '"1__çava verböten"' did not match any files'
775-
""",
776-
)
777765
@with_rw_repo("HEAD", bare=False)
778766
def test_untracked_files(self, rwrepo):
779767
for run, repo_add in enumerate((rwrepo.index.add, rwrepo.git.add)):
@@ -1245,7 +1233,7 @@ def test_merge_base(self):
12451233
def test_is_ancestor(self):
12461234
git = self.rorepo.git
12471235
if git.version_info[:3] < (1, 8, 0):
1248-
raise SkipTest("git merge-base --is-ancestor feature unsupported")
1236+
raise RuntimeError("git merge-base --is-ancestor feature unsupported (test needs git 1.8.0 or later)")
12491237

12501238
repo = self.rorepo
12511239
c1 = "f6aa8d1"
@@ -1293,7 +1281,7 @@ def test_git_work_tree_dotgit(self, rw_dir):
12931281
based on it."""
12941282
git = Git(rw_dir)
12951283
if git.version_info[:3] < (2, 5, 1):
1296-
raise SkipTest("worktree feature unsupported")
1284+
raise RuntimeError("worktree feature unsupported (test needs git 2.5.1 or later)")
12971285

12981286
rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
12991287
branch = rw_master.create_head("aaaaaaaa")

0 commit comments

Comments
 (0)