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

Improve hooks tests#1777

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:mainfromEliahKagan:hooks-tests
Dec 21, 2023
Merged
Changes fromall commits
Commits
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
40 changes: 34 additions & 6 deletionstest/test_index.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,7 @@
InvalidGitRepositoryError,
UnmergedEntriesError,
)
from git.index.fun import hook_path
from git.index.fun import hook_path, run_commit_hook
from git.index.typ import BaseIndexEntry, IndexEntry
from git.objects import Blob
from test.lib import TestBase, fixture, fixture_path, with_rw_directory, with_rw_repo
Expand DownExpand Up@@ -991,9 +991,32 @@ class Mocked:
rel = index._to_relative_path(path)
self.assertEqual(rel, os.path.relpath(path, root))

@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.Absent,
reason="Can't run a hook on Windows without bash.exe.",
rasies=HookExecutionError,
)
@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.WslNoDistro,
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
raises=HookExecutionError,
)
@with_rw_repo("HEAD", bare=True)
def test_run_commit_hook(self, rw_repo):
index = rw_repo.index
_make_hook(index.repo.git_dir, "fake-hook", "echo 'ran fake hook' >output.txt")
run_commit_hook("fake-hook", index)
output = Path(rw_repo.git_dir, "output.txt").read_text(encoding="utf-8")
self.assertEqual(output, "ran fake hook\n")

@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.Absent,
reason="Can't run a hook on Windows without bash.exe.",
rasies=HookExecutionError,
)
@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.WslNoDistro,
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
raises=HookExecutionError,
)
@with_rw_repo("HEAD", bare=True)
Expand All@@ -1004,7 +1027,7 @@ def test_pre_commit_hook_success(self, rw_repo):

@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.WslNoDistro,
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
raises=AssertionError,
)
@with_rw_repo("HEAD", bare=True)
Expand All@@ -1030,13 +1053,18 @@ def test_pre_commit_hook_fail(self, rw_repo):
raise AssertionError("Should have caught a HookExecutionError")

@pytest.mark.xfail(
type(_win_bash_status) in {WinBashStatus.Absent, WinBashStatus.Wsl},
type(_win_bash_status) is WinBashStatus.Absent,
reason="Can't run a hook on Windows without bash.exe.",
rasies=HookExecutionError,
)
@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.Wsl,
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
raises=AssertionError,
)
@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.WslNoDistro,
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
raises=HookExecutionError,
)
@with_rw_repo("HEAD", bare=True)
Expand All@@ -1054,7 +1082,7 @@ def test_commit_msg_hook_success(self, rw_repo):

@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.WslNoDistro,
reason="Currently uses the bash.exefor WSL even with no WSL distro installed",
reason="Currently uses the bash.exeof WSL, even with no WSL distro installed",
raises=AssertionError,
)
@with_rw_repo("HEAD", bare=True)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp