Skip to content

Commit 6e477e3

Browse files
committed
Add xfail marks for IndexFile.from_tree failures
8 of the tests that fail on native Windows systems fail due to IndexFile.from_tree being broken on Windows, causing #1630. This commit marks those tests as xfail. This is part, though not all, of the changes to get CI test jobs for native Windows that are passing, to guard against new regressions and to allow the code and tests to be gradually fixed (see discussion in #1654). When fixing the bug, this commit can be reverted.
1 parent 2fd79f4 commit 6e477e3

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed

test/test_docs.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
import pytest
1010

11+
from git.exc import GitCommandError
1112
from test.lib import TestBase
1213
from test.lib.helper import with_rw_directory
1314

14-
import os.path
15-
1615

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

209+
@pytest.mark.xfail(
210+
os.name == "nt",
211+
reason=(
212+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
213+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
214+
),
215+
raises=GitCommandError,
216+
)
210217
@with_rw_directory
211218
def test_references_and_objects(self, rw_dir):
212219
# [1-test_references_and_objects]

test/test_fun.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
from io import BytesIO
55
from stat import S_IFDIR, S_IFREG, S_IFLNK, S_IXUSR
6-
from os import stat
6+
import os
77
import os.path as osp
88

9+
import pytest
10+
911
from git import Git
12+
from git.exc import GitCommandError
1013
from git.index import IndexFile
1114
from git.index.fun import (
1215
aggressive_tree_merge,
@@ -34,6 +37,14 @@ def _assert_index_entries(self, entries, trees):
3437
assert (entry.path, entry.stage) in index.entries
3538
# END assert entry matches fully
3639

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

293304
dotgit = osp.join(worktree_path, ".git")
294-
statbuf = stat(dotgit)
305+
statbuf = os.stat(dotgit)
295306
self.assertTrue(statbuf.st_mode & S_IFREG)
296307

297308
gitdir = find_worktree_git_dir(dotgit)
298309
self.assertIsNotNone(gitdir)
299-
statbuf = stat(gitdir)
310+
statbuf = os.stat(gitdir)
300311
self.assertTrue(statbuf.st_mode & S_IFDIR)
301312

302313
def test_tree_entries_from_data_with_failing_name_decode_py3(self):

test/test_index.py

+40
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ def add_bad_blob():
179179
except Exception as ex:
180180
assert "index.lock' could not be obtained" not in str(ex)
181181

182+
@pytest.mark.xfail(
183+
os.name == "nt",
184+
reason=(
185+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
186+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
187+
),
188+
raises=GitCommandError,
189+
)
182190
@with_rw_repo("0.1.6")
183191
def test_index_file_from_tree(self, rw_repo):
184192
common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541"
@@ -229,6 +237,14 @@ def test_index_file_from_tree(self, rw_repo):
229237
# END for each blob
230238
self.assertEqual(num_blobs, len(three_way_index.entries))
231239

240+
@pytest.mark.xfail(
241+
os.name == "nt",
242+
reason=(
243+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
244+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
245+
),
246+
raises=GitCommandError,
247+
)
232248
@with_rw_repo("0.1.6")
233249
def test_index_merge_tree(self, rw_repo):
234250
# A bit out of place, but we need a different repo for this:
@@ -291,6 +307,14 @@ def test_index_merge_tree(self, rw_repo):
291307
self.assertEqual(len(unmerged_blobs), 1)
292308
self.assertEqual(list(unmerged_blobs.keys())[0], manifest_key[0])
293309

310+
@pytest.mark.xfail(
311+
os.name == "nt",
312+
reason=(
313+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
314+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
315+
),
316+
raises=GitCommandError,
317+
)
294318
@with_rw_repo("0.1.6")
295319
def test_index_file_diffing(self, rw_repo):
296320
# Default Index instance points to our index.
@@ -425,6 +449,14 @@ def _count_existing(self, repo, files):
425449

426450
# END num existing helper
427451

452+
@pytest.mark.xfail(
453+
os.name == "nt",
454+
reason=(
455+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
456+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
457+
),
458+
raises=GitCommandError,
459+
)
428460
@with_rw_repo("0.1.6")
429461
def test_index_mutation(self, rw_repo):
430462
index = rw_repo.index
@@ -778,6 +810,14 @@ def make_paths():
778810
for absfile in absfiles:
779811
assert osp.isfile(absfile)
780812

813+
@pytest.mark.xfail(
814+
os.name == "nt",
815+
reason=(
816+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
817+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
818+
),
819+
raises=GitCommandError,
820+
)
781821
@with_rw_repo("HEAD")
782822
def test_compare_write_tree(self, rw_repo):
783823
"""Test writing all trees, comparing them for equality."""

test/test_refs.py

+11
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
55

66
from itertools import chain
7+
import os
78
from pathlib import Path
89

10+
import pytest
11+
912
from git import (
1013
Reference,
1114
Head,
@@ -215,6 +218,14 @@ def test_head_checkout_detached_head(self, rw_repo):
215218
assert isinstance(res, SymbolicReference)
216219
assert res.name == "HEAD"
217220

221+
@pytest.mark.xfail(
222+
os.name == "nt",
223+
reason=(
224+
"IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n"
225+
"'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'."
226+
),
227+
raises=GitCommandError,
228+
)
218229
@with_rw_repo("0.1.6")
219230
def test_head_reset(self, rw_repo):
220231
cur_head = rw_repo.head

0 commit comments

Comments
 (0)