Skip to content

Commit f664a0b

Browse files
committed
Add xfail marks to hook tests for WinBashStatus.Absent
Precise xfail marks were added to commit hook tests in #1745, but in a few tests I didn't get it right for WinBashStatus.Absent. That is, on a Windows system that has no bash.exe at all: - More of the tests are unable to pass than have xfail marks. - One of the tests, test_commit_msg_hook_success, which does have an xfail mark for that, wrongly combines it with the xfail mark for WinBashStatus.Wsl. That test is the only one where the WSL bash.exe, even when a working WSL distribution is installed, is unable to pass. But using a single mark there is wrong, in part because the "reason" is not correct for both, but even more so because the exceptions they raise are different: AssertionError is raised when the WSL bash.exe is used in that test, but when bash.exe is altogether absent, HookExecutionError is raised. This fixes that by adding xfail marks for WinBashStatus.Absent where missing, and splitting test_commit_msg_hook_success's xfail mark that unsuccessfully tried to cover two conditions into two separate marks, each of which gives a correct reason and exception. This commit also rewords the xfail reason given for WslNoDistro, which was somewhat unclear and potentially ambiguous, to make it clearer.
1 parent 4023f28 commit f664a0b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: test/test_index.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -991,9 +991,14 @@ class Mocked:
991991
rel = index._to_relative_path(path)
992992
self.assertEqual(rel, os.path.relpath(path, root))
993993

994+
@pytest.mark.xfail(
995+
type(_win_bash_status) is WinBashStatus.Absent,
996+
reason="Can't run a hook on Windows without bash.exe.",
997+
rasies=HookExecutionError,
998+
)
994999
@pytest.mark.xfail(
9951000
type(_win_bash_status) is WinBashStatus.WslNoDistro,
996-
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
1001+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
9971002
raises=HookExecutionError,
9981003
)
9991004
@with_rw_repo("HEAD", bare=True)
@@ -1004,7 +1009,7 @@ def test_pre_commit_hook_success(self, rw_repo):
10041009

10051010
@pytest.mark.xfail(
10061011
type(_win_bash_status) is WinBashStatus.WslNoDistro,
1007-
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
1012+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
10081013
raises=AssertionError,
10091014
)
10101015
@with_rw_repo("HEAD", bare=True)
@@ -1030,13 +1035,18 @@ def test_pre_commit_hook_fail(self, rw_repo):
10301035
raise AssertionError("Should have caught a HookExecutionError")
10311036

10321037
@pytest.mark.xfail(
1033-
type(_win_bash_status) in {WinBashStatus.Absent, WinBashStatus.Wsl},
1038+
type(_win_bash_status) is WinBashStatus.Absent,
1039+
reason="Can't run a hook on Windows without bash.exe.",
1040+
rasies=HookExecutionError,
1041+
)
1042+
@pytest.mark.xfail(
1043+
type(_win_bash_status) is WinBashStatus.Wsl,
10341044
reason="Specifically seems to fail on WSL bash (in spite of #1399)",
10351045
raises=AssertionError,
10361046
)
10371047
@pytest.mark.xfail(
10381048
type(_win_bash_status) is WinBashStatus.WslNoDistro,
1039-
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
1049+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
10401050
raises=HookExecutionError,
10411051
)
10421052
@with_rw_repo("HEAD", bare=True)
@@ -1054,7 +1064,7 @@ def test_commit_msg_hook_success(self, rw_repo):
10541064

10551065
@pytest.mark.xfail(
10561066
type(_win_bash_status) is WinBashStatus.WslNoDistro,
1057-
reason="Currently uses the bash.exe for WSL even with no WSL distro installed",
1067+
reason="Currently uses the bash.exe of WSL, even with no WSL distro installed",
10581068
raises=AssertionError,
10591069
)
10601070
@with_rw_repo("HEAD", bare=True)

0 commit comments

Comments
 (0)