Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hooks tests #1777

Merged
merged 2 commits into from
Dec 21, 2023
Merged

Improve hooks tests #1777

merged 2 commits into from
Dec 21, 2023

Commits on Dec 21, 2023

  1. Add xfail marks to hook tests for WinBashStatus.Absent

    Precise xfail marks were added to commit hook tests in gitpython-developers#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.
    EliahKagan committed Dec 21, 2023
    Configuration menu
    Copy the full SHA
    f664a0b View commit details
    Browse the repository at this point in the history
  2. Add a direct test of run_commit_hook

    This has three benefits:
    
    - run_commit_hook is public, being listed in git.index.fun.__all__,
      so it makes sense for it to have its own test.
    
    - When investigating (future, or current xfail-covered) failure of
      functions that use run_commit_hook, it will be useful to compare
      the results of other tests that already do exist to that of a
      direct test of run_commit_hook.
    
    - When changing which bash.exe run_commit_hook selects to use on
      Windows (including to ameliorate the limitation covered by the
      WinBashStatus.WslNoDistro xfail marks, or to attempt other
      possible changes suggested in gitpython-developers#1745), or even just to investigate
      the possibility of doing so, it will make sense to add tests like
      this test but for more specific conditions or edge cases. Having
      this typical-case test to compare to should be helpful both for
      writing such tests and for efficiently verifying that the
      conditions they test are really the triggers for any failures.
    EliahKagan committed Dec 21, 2023
    Configuration menu
    Copy the full SHA
    e148647 View commit details
    Browse the repository at this point in the history