]> git.ipfire.org Git - thirdparty/git.git/commit
test-lib-functions: add and use a "test_hook" wrapper
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 17 Mar 2022 10:13:06 +0000 (11:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Mar 2022 15:40:25 +0000 (08:40 -0700)
commit7da7f63cf9950d0ecd83579b4ca28f7b2805bf32
tree36ab7f7b1abf82d68d6b50df8a018009b64a233b
parent74cc1aa55f30ed76424a0e7226ab519aa6265061
test-lib-functions: add and use a "test_hook" wrapper

Add a "test_hook" wrapper similar to the existing "test_config"
wrapper added in d960c47a881 (test-lib: add helper functions for
config, 2011-08-17).

This wrapper:

 - Will clean up the hook with "test_when_finished", unless --setup is
   provided.

 - Will error if we clobber a hook, unless --clobber is provided.

 - Takes a name like "update" instead of ".git/hooks/update".

 - Accepts -C <dir>, like "test_config" and "test_commit".

By using a wrapper we'll be able to easily change all the hook-related
code that assumes that the template-created ".git/hooks" directory is
created by "init", "clone" etc. once another topic follows-up and
changes the test suite to stop creating trash directories using those
templates.

In addition this will make it easy to have the hooks configured using
the "configuration-based hooks" topic, once we get around to
integrating that. I.e. we'll be able to run the tests in a mode where
we sometimes create a .git/hooks/<name>, and other times create a
script in another location, and point the relevant configuration
snippet to it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
13 files changed:
t/t1416-ref-transaction-hooks.sh
t/t1800-hook.sh
t/t5401-update-hooks.sh
t/t5406-remote-rejects.sh
t/t5409-colorize-remote-messages.sh
t/t5411-proc-receive-hook.sh
t/t5503-tagfollow.sh
t/t5510-fetch.sh
t/t5521-pull-options.sh
t/t5547-push-quarantine.sh
t/t5548-push-porcelain.sh
t/t7519-status-fsmonitor.sh
t/test-lib-functions.sh