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

Test native Windows on CI #1745

Merged
merged 29 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2fd79f4
Add native Windows test jobs to CI matrix
EliahKagan Oct 15, 2023
6e477e3
Add xfail marks for IndexFile.from_tree failures
EliahKagan Nov 14, 2023
cd9d7a9
Mark test_clone_command_injection xfail on Windows
EliahKagan Nov 15, 2023
f72e282
Mark test_diff_submodule xfail on Windows
EliahKagan Nov 15, 2023
42a3d74
Mark TestSubmodule.test_rename xfail on Windows
EliahKagan Nov 15, 2023
4abab92
Mark test_conditional_includes_from_git_dir xfail on Windows
EliahKagan Nov 15, 2023
799c853
Improve ordering/grouping of a few imports
EliahKagan Nov 16, 2023
b284ad7
Mark test_create_remote_unsafe_url_allowed xfail on Windows
EliahKagan Nov 16, 2023
61d1fba
Mark unsafe-options "allowed" tests xfail on Windows
EliahKagan Nov 16, 2023
ad07ecb
Show PATH on CI
EliahKagan Nov 22, 2023
2784e40
Show bash and other WSL-relevant info but not PATH
EliahKagan Nov 22, 2023
9717b8d
Install WSL system on CI for hook tests
EliahKagan Nov 17, 2023
5d11394
Fix and expand bash.exe xfail marks on hook tests
EliahKagan Nov 23, 2023
b215357
Simplify/clarify bash.exe check for hook tests; do it only once
EliahKagan Nov 24, 2023
cabb572
Temporarily don't install WSL system to test xfail
EliahKagan Nov 24, 2023
2875ffa
Put back WSL on Windows CI; pare down debug info
EliahKagan Nov 24, 2023
0f8cd4c
Treat XPASS status as a test failure
EliahKagan Nov 24, 2023
82c361e
Correct TestSubmodule.test_rename xfail condition
EliahKagan Nov 24, 2023
0ae5dd1
Revert "Treat XPASS status as a test failure"
EliahKagan Nov 24, 2023
0b7ee17
Refine TestSubmodule.test_rename xfail condition
EliahKagan Nov 25, 2023
8621e89
Reword comment in _WinBashStatus.check for clarity
EliahKagan Nov 25, 2023
7ff3cee
Make _WinBashStatus instances carry all their info
EliahKagan Nov 25, 2023
d5ed266
Use bytes in bash.exe check; retest no-distro case
EliahKagan Nov 25, 2023
496acaa
Handle multiple encodings for WSL error messages
EliahKagan Nov 26, 2023
d779a75
Don't assume WSL-related bash.exe error is English
EliahKagan Nov 27, 2023
9ac2438
Handle encodings better; make the sum type "public"
EliahKagan Nov 27, 2023
b07e5c7
Put back WSL on Windows CI
EliahKagan Nov 28, 2023
3303c74
Improve readability of WinBashStatus class
EliahKagan Nov 28, 2023
e00fffc
Shorten comments on _decode steps
EliahKagan Nov 28, 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
4 changes: 1 addition & 3 deletions .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ jobs:
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)' # NOTE: Deprecated. Use os.name directly.
python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'

- name: Test with pytest
run: |
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ permissions:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- experimental: false

runs-on: ${{ matrix.os }}

defaults:
run:
shell: /bin/bash --noprofile --norc -exo pipefail {0}
shell: bash --noprofile --norc -exo pipefail {0}

steps:
- uses: actions/checkout@v4
Expand All @@ -34,6 +35,12 @@ jobs:
python-version: ${{ matrix.python-version }}
allow-prereleases: ${{ matrix.experimental }}

- name: Set up WSL (Windows)
if: startsWith(matrix.os, 'windows')
uses: Vampire/setup-wsl@v2.0.2
with:
distribution: Debian

- name: Prepare this repo for tests
run: |
./init-tests-after-clone.sh
Expand Down Expand Up @@ -61,9 +68,16 @@ jobs:
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)' # NOTE: Deprecated. Use os.name directly.
python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'

# For debugging hook tests on native Windows systems that may have WSL.
- name: Show bash.exe candidates (Windows)
if: startsWith(matrix.os, 'windows')
run: |
set +e
bash.exe -c 'printenv WSL_DISTRO_NAME; uname -a'
python -c 'import subprocess; subprocess.run(["bash.exe", "-c", "printenv WSL_DISTRO_NAME; uname -a"])'
continue-on-error: true

- name: Check types with mypy
run: |
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pytest-cov
pytest-instafail
pytest-mock
pytest-sugar
sumtypes
17 changes: 9 additions & 8 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
import glob
import io
import os
import os.path as osp
from unittest import mock

import pytest

from git import GitConfigParser
from git.config import _OMD, cp
from test.lib import (
TestCase,
fixture_path,
SkipTest,
)
from test.lib import with_rw_directory

import os.path as osp
from git.util import rmfile
from test.lib import SkipTest, TestCase, fixture_path, with_rw_directory


_tc_lock_fpaths = osp.join(osp.dirname(__file__), "fixtures/*.lock")
Expand Down Expand Up @@ -239,6 +235,11 @@ def check_test_value(cr, value):
with GitConfigParser(fpa, read_only=True) as cr:
check_test_value(cr, tv)

@pytest.mark.xfail(
os.name == "nt",
reason='Second config._has_includes() assertion fails (for "config is included if path is matching git_dir")',
raises=AssertionError,
)
@with_rw_directory
def test_conditional_includes_from_git_dir(self, rw_dir):
# Initiate repository path.
Expand Down
30 changes: 13 additions & 17 deletions test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/

import ddt
import os
import os.path as osp
import shutil
import tempfile
from git import (
Repo,
GitCommandError,
Diff,
DiffIndex,
NULL_TREE,
Submodule,
)
from git.cmd import Git
from test.lib import (
TestBase,
StringProcessAdapter,
fixture,
)
from test.lib import with_rw_directory

import os.path as osp
import ddt
import pytest

from git import NULL_TREE, Diff, DiffIndex, GitCommandError, Repo, Submodule
from git.cmd import Git
from test.lib import StringProcessAdapter, TestBase, fixture, with_rw_directory


def to_raw(input):
Expand Down Expand Up @@ -318,6 +309,11 @@ def test_diff_with_spaces(self):
self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path))
self.assertEqual(diff_index[0].b_path, "file with spaces", repr(diff_index[0].b_path))

@pytest.mark.xfail(
os.name == "nt",
reason='"Access is denied" when tearDown calls shutil.rmtree',
raises=PermissionError,
)
def test_diff_submodule(self):
"""Test that diff is able to correctly diff commits that cover submodule changes"""
# Init a temp git repo that will be referenced as a submodule.
Expand Down
11 changes: 9 additions & 2 deletions test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

import pytest

from git.exc import GitCommandError
from test.lib import TestBase
from test.lib.helper import with_rw_directory

import os.path


class Tutorials(TestBase):
def tearDown(self):
Expand Down Expand Up @@ -207,6 +206,14 @@ def update(self, op_code, cur_count, max_count=None, message=""):
assert sm.module_exists() # The submodule's working tree was checked out by update.
# ![14-test_init_repo_object]

@pytest.mark.xfail(
os.name == "nt",
reason=(
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
),
raises=GitCommandError,
)
@with_rw_directory
def test_references_and_objects(self, rw_dir):
# [1-test_references_and_objects]
Expand Down
17 changes: 14 additions & 3 deletions test/test_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

from io import BytesIO
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
from os import stat
import os
import os.path as osp

import pytest

from git import Git
from git.exc import GitCommandError
from git.index import IndexFile
from git.index.fun import (
aggressive_tree_merge,
Expand Down Expand Up @@ -34,6 +37,14 @@ def _assert_index_entries(self, entries, trees):
assert (entry.path, entry.stage) in index.entries
# END assert entry matches fully

@pytest.mark.xfail(
os.name == "nt",
reason=(
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
),
raises=GitCommandError,
)
def test_aggressive_tree_merge(self):
# Head tree with additions, removals and modification compared to its predecessor.
odb = self.rorepo.odb
Expand Down Expand Up @@ -291,12 +302,12 @@ def test_linked_worktree_traversal(self, rw_dir):
rw_master.git.worktree("add", worktree_path, branch.name)

dotgit = osp.join(worktree_path, ".git")
statbuf = stat(dotgit)
statbuf = os.stat(dotgit)
self.assertTrue(statbuf.st_mode & S_IFREG)

gitdir = find_worktree_git_dir(dotgit)
self.assertIsNotNone(gitdir)
statbuf = stat(gitdir)
statbuf = os.stat(gitdir)
self.assertTrue(statbuf.st_mode & S_IFDIR)

def test_tree_entries_from_data_with_failing_name_decode_py3(self):
Expand Down
Loading
Loading