Merge pull request #1679 from EliahKagan/verbose-ci · gitpython-developers/GitPython@58076c2 · GitHub
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

Lines changed: 119 additions & 130 deletions

.github/workflows/cygwin-test.yml

Lines changed: 27 additions & 17 deletions

.github/workflows/lint.yml

Lines changed: 7 additions & 5 deletions
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

Lines changed: 16 additions & 14 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 23 additions & 19 deletions
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

Lines changed: 5 additions & 17 deletions

0 commit comments

Comments
 (0)