Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make clear every test's status in every CI run #1679

Merged
merged 32 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
45773c2
Instrument workflows to investigate skipped tests
EliahKagan Sep 7, 2023
6fbe511
Show version and platform info in one place
EliahKagan Sep 13, 2023
bd3307a
Make "Update PyPA packages" step clearer
EliahKagan Sep 13, 2023
680d795
Show all the failures
EliahKagan Sep 13, 2023
75cf540
Keep sugar for local use, but use instafail on CI
EliahKagan Sep 14, 2023
eb56e7b
Pass -v twice to see full skip reasons
EliahKagan Sep 14, 2023
9c7ff1e
Force pytest color output on CI
EliahKagan Sep 14, 2023
0eb38bc
Fix test_blocking_lock_file for cygwin
EliahKagan Sep 15, 2023
715dba4
Run cygpath tests on Cygwin, not native Windows
EliahKagan Sep 14, 2023
d6a2d28
Mark some cygpath tests xfail
EliahKagan Sep 17, 2023
881456b
Run test_commit_msg_hook_success on more systems
EliahKagan Sep 17, 2023
c6a586a
No longer skip test_index_mutation on Cygwin
EliahKagan Sep 17, 2023
fc02230
Report encoding error in test_add_unicode as error
EliahKagan Sep 24, 2023
203da23
Add a few FIXMEs re: better use of xfail
EliahKagan Sep 24, 2023
cf5f1dc
Report <2.5.1 in test_linked_worktree_traversal as error
EliahKagan Sep 25, 2023
8923236
Change skipIf(not ...) to skipUnless(...)
EliahKagan Sep 25, 2023
b198bf1
Express known test_depth failure with xfail
EliahKagan Sep 25, 2023
cd175a5
Remove no-effect `@skipIf` on test_untracked_files
EliahKagan Sep 25, 2023
f38cc00
Make 2 more too-low git version skips into errors
EliahKagan Sep 25, 2023
8fd56e7
Update test_root_module Windows skip reason
EliahKagan Sep 25, 2023
c1798f5
Change test_root_module Windows skip to xfail
EliahKagan Sep 25, 2023
ba56752
Update test_git_submodules_and_add_sm_with_new_commit skip reason
EliahKagan Sep 25, 2023
8704d1b
Change test_git_submodules_and_add_sm_with_new_commit Windows skip to…
EliahKagan Sep 25, 2023
1d6abdc
Run the tests in test_tree on Windows
EliahKagan Sep 25, 2023
5609faa
Add missing raises keyword for test_depth xfail
EliahKagan Sep 25, 2023
ed95e8e
Consolidate test_repo module import statements
EliahKagan Sep 25, 2023
ceb4dd3
Show more CI system information
EliahKagan Sep 25, 2023
3276aac
Use Cygwin's bash and git for more CI steps
EliahKagan Sep 25, 2023
5d40976
Try to work in all LF on Cygwin CI
EliahKagan Sep 25, 2023
dda4286
Consistent formatting style across all workflows
EliahKagan Sep 25, 2023
3007abc
Remove the recently added "Limit $PATH" step
EliahKagan Sep 26, 2023
4860f70
Further reduce differences between test workflows
EliahKagan Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@ on: [push, pull_request, workflow_dispatch]
jobs:
build:
runs-on: windows-latest

strategy:
fail-fast: false

env:
CHERE_INVOKING: 1
SHELLOPTS: igncr
TMP: "/tmp"
TEMP: "/tmp"

defaults:
run:
shell: bash.exe --noprofile --norc -exo pipefail -o igncr "{0}"
shell: C:\cygwin\bin\bash.exe --noprofile --norc -exo pipefail -o igncr "{0}"

steps:
- name: Force LF line endings
run: git config --global core.autocrlf input
run: |
git config --global core.autocrlf false # Affects the non-Cygwin git.
shell: bash

- uses: actions/checkout@v4
with:
Expand All @@ -29,36 +33,42 @@ jobs:
with:
packages: python39 python39-pip python39-virtualenv git

- name: Show python and git versions
- name: Special configuration for Cygwin's git
run: |
/usr/bin/python --version
/usr/bin/git version

- name: Tell git to trust this repo
run: |
/usr/bin/git config --global --add safe.directory "$(pwd)"
git config --global --add safe.directory "$(pwd)"
git config --global core.autocrlf false

- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh

- name: Further prepare git configuration for tests
- name: Set git user identity and command aliases for the tests
run: |
/usr/bin/git config --global user.email "travis@ci.com"
/usr/bin/git config --global user.name "Travis Runner"
git config --global user.email "travis@ci.com"
git config --global user.name "Travis Runner"
# If we rewrite the user's config by accident, we will mess it up
# and cause subsequent tests to fail
cat test/fixtures/.gitconfig >> ~/.gitconfig

- name: Update PyPA packages
run: |
/usr/bin/python -m pip install --upgrade pip setuptools wheel
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
python -m pip install -U pip $(pip freeze --all | grep -oF setuptools) wheel

- name: Install project and test dependencies
run: |
/usr/bin/python -m pip install ".[test]"
python -m pip install ".[test]"

- name: Show version and platform information
run: |
uname -a
command -v git python
git version
python --version
python -c 'import sys; print(sys.platform)'
python -c 'import os; print(os.name)'
python -c 'import git; print(git.compat.is_win)'

- name: Test with pytest
run: |
set +x
/usr/bin/python -m pytest
python -m pytest --color=yes -p no:sugar --instafail -vv
12 changes: 7 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- uses: pre-commit/action@v3.0.0
30 changes: 16 additions & 14 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
Expand All @@ -20,6 +20,7 @@ jobs:
- experimental: false
- python-version: "3.12"
experimental: true

defaults:
run:
shell: /bin/bash --noprofile --norc -exo pipefail {0}
Expand All @@ -36,16 +37,11 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.experimental }}

- name: Show python and git versions
run: |
python --version
git version

- name: Prepare this repo for tests
run: |
TRAVIS=yes ./init-tests-after-clone.sh

- name: Prepare git configuration for tests
- name: Set git user identity and command aliases for the tests
run: |
git config --global user.email "travis@ci.com"
git config --global user.name "Travis Runner"
Expand All @@ -55,17 +51,23 @@ jobs:

- name: Update PyPA packages
run: |
python -m pip install --upgrade pip
if pip freeze --all | grep --quiet '^setuptools=='; then
# Python prior to 3.12 ships setuptools. Upgrade it if present.
python -m pip install --upgrade setuptools
fi
python -m pip install --upgrade wheel
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
python -m pip install -U pip $(pip freeze --all | grep -oF setuptools) wheel

- name: Install project and test dependencies
run: |
pip install ".[test]"

- name: Show version and platform information
run: |
uname -a
command -v git python
git version
python --version
python -c 'import sys; print(sys.platform)'
python -c 'import os; print(os.name)'
python -c 'import git; print(git.compat.is_win)'

- name: Check types with mypy
run: |
mypy -p git
Expand All @@ -75,7 +77,7 @@ jobs:

- name: Test with pytest
run: |
pytest
pytest --color=yes -p no:sugar --instafail -vv
continue-on-error: false

- name: Documentation
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
python_files = 'test_*.py'
testpaths = 'test' # space separated list of paths from root e.g test tests doc/testing
addopts = '--cov=git --cov-report=term --maxfail=10 --force-sugar --disable-warnings'
addopts = '--cov=git --cov-report=term --disable-warnings'
filterwarnings = 'ignore::DeprecationWarning'
# --cov coverage
# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mypy
pre-commit
pytest
pytest-cov
pytest-instafail
pytest-sugar
4 changes: 2 additions & 2 deletions test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
import sys
import tempfile
from unittest import SkipTest, skipIf
from unittest import skipIf

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

with open(file_path, "wb") as fp:
fp.write(b"something")
Expand Down
1 change: 1 addition & 0 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_includes_order(self):
# values must be considered as soon as they get them
assert r_config.get_value("diff", "tool") == "meld"
try:
# FIXME: Split this assertion out somehow and mark it xfail (or fix it).
assert r_config.get_value("sec", "var1") == "value1_main"
except AssertionError as e:
raise SkipTest("Known failure -- included values are not in effect right away") from e
Expand Down
3 changes: 1 addition & 2 deletions test/test_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
from os import stat
import os.path as osp
from unittest import SkipTest

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

rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
branch = rw_master.create_head("aaaaaaaa")
Expand Down
42 changes: 23 additions & 19 deletions test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

from io import BytesIO
import os
import os.path as osp
from pathlib import Path
from stat import S_ISLNK, ST_MODE
import tempfile
from unittest import skipIf
import shutil
import tempfile

import pytest

from git import (
IndexFile,
Expand All @@ -28,21 +31,26 @@
from git.index.fun import hook_path
from git.index.typ import BaseIndexEntry, IndexEntry
from git.objects import Blob
from test.lib import TestBase, fixture_path, fixture, with_rw_repo
from test.lib import with_rw_directory
from git.util import Actor, rmtree
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, hex_to_bin
from test.lib import TestBase, fixture, fixture_path, with_rw_directory, with_rw_repo
from git.util import Actor, hex_to_bin, rmtree
from gitdb.base import IStream

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

from pathlib import Path

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


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

is_win_with_wsl_bash = is_win and _found_in(
cmd="bash.exe",
directory=Path(os.getenv("WINDIR")) / "System32",
)


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

# END num existing helper

@skipIf(
HIDE_WINDOWS_KNOWN_ERRORS and Git.is_cygwin(),
"""FIXME: File "C:\\projects\\gitpython\\git\\test\\test_index.py", line 642, in test_index_mutation
self.assertEqual(fd.read(), link_target)
AssertionError: '!<symlink>\xff\xfe/\x00e\x00t\x00c\x00/\x00t\x00h\x00a\x00t\x00\x00\x00'
!= '/etc/that'
""",
)
@with_rw_repo("0.1.6")
def test_index_mutation(self, rw_repo):
index = rw_repo.index
Expand Down Expand Up @@ -910,7 +910,11 @@ def test_pre_commit_hook_fail(self, rw_repo):
else:
raise AssertionError("Should have caught a HookExecutionError")

@skipIf(HIDE_WINDOWS_KNOWN_ERRORS, "TODO: fix hooks execution on Windows: #703")
@pytest.mark.xfail(
is_win_without_bash or is_win_with_wsl_bash,
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
raises=AssertionError,
)
@with_rw_repo("HEAD", bare=True)
def test_commit_msg_hook_success(self, rw_repo):
commit_message = "commit default head by Frèderic Çaufl€"
Expand Down
22 changes: 5 additions & 17 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pickle
import sys
import tempfile
from unittest import mock, skipIf, SkipTest, skip
from unittest import mock, skip

import pytest

Expand Down Expand Up @@ -41,10 +41,8 @@
UnsafeProtocolError,
)
from git.repo.fun import touch
from test.lib import TestBase, with_rw_repo, fixture
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
from test.lib import with_rw_directory
from git.util import join_path_native, rmtree, rmfile, bin_to_hex
from git.util import bin_to_hex, cygpath, join_path_native, rmfile, rmtree
from test.lib import TestBase, fixture, with_rw_directory, with_rw_repo

import os.path as osp

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

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

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

rw_master = self.rorepo.clone(join_path_native(rw_dir, "master_repo"))
branch = rw_master.create_head("aaaaaaaa")
Expand Down
Loading