Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit881456b

Browse files
committed
Run test_commit_msg_hook_success on more systems
This changes a default Windows skip of test_commit_msg_hook_successto an xfail, and makes it more specific, expecting failure onlywhen either bash.exe is unavailable (definitely expected) or whenbash.exe is the WSL bash wrapper in System32, which fails for somereason even though it's not at all clear it ought to.This showcases the failures rather than skipping, and also lets thetest pass on Windows systems where bash.exe is something else,including the Git Bash bash.exe that native Windows CI would use.
1 parentd6a2d28 commit881456b

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎test/test_index.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
fromioimportBytesIO
99
importos
10+
importos.pathasosp
11+
frompathlibimportPath
1012
fromstatimportS_ISLNK,ST_MODE
13+
importshutil
1114
importtempfile
1215
fromunittestimportskipIf
13-
importshutil
16+
17+
importpytest
1418

1519
fromgitimport (
1620
IndexFile,
@@ -23,6 +27,7 @@
2327
GitCommandError,
2428
CheckoutError,
2529
)
30+
fromgit.cmdimportGit
2631
fromgit.compatimportis_win
2732
fromgit.excimportHookExecutionError,InvalidGitRepositoryError
2833
fromgit.index.funimporthook_path
@@ -34,15 +39,22 @@
3439
fromgit.utilimportHIDE_WINDOWS_KNOWN_ERRORS,hex_to_bin
3540
fromgitdb.baseimportIStream
3641

37-
importos.pathasosp
38-
fromgit.cmdimportGit
42+
HOOKS_SHEBANG="#!/usr/bin/env sh\n"
3943

40-
frompathlibimportPath
4144

42-
HOOKS_SHEBANG="#!/usr/bin/env sh\n"
45+
def_found_in(cmd,directory):
46+
"""Check if a command is resolved in a directory (without following symlinks)."""
47+
path=shutil.which(cmd)
48+
returnpathandPath(path).parent==Path(directory)
49+
4350

4451
is_win_without_bash=is_winandnotshutil.which("bash.exe")
4552

53+
is_win_with_wsl_bash=is_winand_found_in(
54+
cmd="bash.exe",
55+
directory=Path(os.getenv("WINDIR"))/"System32",
56+
)
57+
4658

4759
def_make_hook(git_dir,name,content,make_exec=True):
4860
"""A helper to create a hook"""
@@ -910,7 +922,11 @@ def test_pre_commit_hook_fail(self, rw_repo):
910922
else:
911923
raiseAssertionError("Should have caught a HookExecutionError")
912924

913-
@skipIf(HIDE_WINDOWS_KNOWN_ERRORS,"TODO: fix hooks execution on Windows: #703")
925+
@pytest.mark.xfail(
926+
is_win_without_bashoris_win_with_wsl_bash,
927+
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
928+
raises=AssertionError,
929+
)
914930
@with_rw_repo("HEAD",bare=True)
915931
deftest_commit_msg_hook_success(self,rw_repo):
916932
commit_message="commit default head by Frèderic Çaufl€"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp