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

Commitc398d79

Browse files
authored
Merge pull request#1777 from EliahKagan/hooks-tests
Improve hooks tests
2 parents22129a7 +e148647 commitc398d79

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

‎test/test_index.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
InvalidGitRepositoryError,
3333
UnmergedEntriesError,
3434
)
35-
fromgit.index.funimporthook_path
35+
fromgit.index.funimporthook_path,run_commit_hook
3636
fromgit.index.typimportBaseIndexEntry,IndexEntry
3737
fromgit.index.utilimportTemporaryFileSwap
3838
fromgit.objectsimportBlob
@@ -992,9 +992,32 @@ class Mocked:
992992
rel=index._to_relative_path(path)
993993
self.assertEqual(rel,os.path.relpath(path,root))
994994

995+
@pytest.mark.xfail(
996+
type(_win_bash_status)isWinBashStatus.Absent,
997+
reason="Can't run a hook on Windows without bash.exe.",
998+
rasies=HookExecutionError,
999+
)
9951000
@pytest.mark.xfail(
9961001
type(_win_bash_status)isWinBashStatus.WslNoDistro,
997-
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
1002+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
1003+
raises=HookExecutionError,
1004+
)
1005+
@with_rw_repo("HEAD",bare=True)
1006+
deftest_run_commit_hook(self,rw_repo):
1007+
index=rw_repo.index
1008+
_make_hook(index.repo.git_dir,"fake-hook","echo 'ran fake hook' >output.txt")
1009+
run_commit_hook("fake-hook",index)
1010+
output=Path(rw_repo.git_dir,"output.txt").read_text(encoding="utf-8")
1011+
self.assertEqual(output,"ran fake hook\n")
1012+
1013+
@pytest.mark.xfail(
1014+
type(_win_bash_status)isWinBashStatus.Absent,
1015+
reason="Can't run a hook on Windows without bash.exe.",
1016+
rasies=HookExecutionError,
1017+
)
1018+
@pytest.mark.xfail(
1019+
type(_win_bash_status)isWinBashStatus.WslNoDistro,
1020+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
9981021
raises=HookExecutionError,
9991022
)
10001023
@with_rw_repo("HEAD",bare=True)
@@ -1005,7 +1028,7 @@ def test_pre_commit_hook_success(self, rw_repo):
10051028

10061029
@pytest.mark.xfail(
10071030
type(_win_bash_status)isWinBashStatus.WslNoDistro,
1008-
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
1031+
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
10091032
raises=AssertionError,
10101033
)
10111034
@with_rw_repo("HEAD",bare=True)
@@ -1031,13 +1054,18 @@ def test_pre_commit_hook_fail(self, rw_repo):
10311054
raiseAssertionError("Should have caught a HookExecutionError")
10321055

10331056
@pytest.mark.xfail(
1034-
type(_win_bash_status)in {WinBashStatus.Absent,WinBashStatus.Wsl},
1057+
type(_win_bash_status)isWinBashStatus.Absent,
1058+
reason="Can't run a hook on Windows without bash.exe.",
1059+
rasies=HookExecutionError,
1060+
)
1061+
@pytest.mark.xfail(
1062+
type(_win_bash_status)isWinBashStatus.Wsl,
10351063
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
10361064
raises=AssertionError,
10371065
)
10381066
@pytest.mark.xfail(
10391067
type(_win_bash_status)isWinBashStatus.WslNoDistro,
1040-
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
1068+
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
10411069
raises=HookExecutionError,
10421070
)
10431071
@with_rw_repo("HEAD",bare=True)
@@ -1055,7 +1083,7 @@ def test_commit_msg_hook_success(self, rw_repo):
10551083

10561084
@pytest.mark.xfail(
10571085
type(_win_bash_status)isWinBashStatus.WslNoDistro,
1058-
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
1086+
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
10591087
raises=AssertionError,
10601088
)
10611089
@with_rw_repo("HEAD",bare=True)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp