diff options
| author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-03-17 11:13:16 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-03-17 14:42:14 -0700 |
| commit | 66865d12a0a15276fd525a461e0873bf82d4f246 (patch) | |
| tree | eb67caff7a3c52a90028da006282c0fc660b3b84 /t/test-lib-functions.sh | |
| parent | tests: use "test_hook" for misc "mkdir -p" and "chmod" cases (diff) | |
| download | git-66865d12a0a15276fd525a461e0873bf82d4f246.tar.gz git-66865d12a0a15276fd525a461e0873bf82d4f246.zip | |
tests: extend "test_hook" for "rm" and "chmod -x", convert "$HOOK"
Extend the "test_hook" function to take options to disable and remove
hooks. Using the wrapper instead of getting the path and running
"chmod -x" or "rm" will make it easier to eventually emulate the same
behavior with config-based hooks.
Not all of these tests need that new mode, but since the rest are
either closely related or use the same "$HOOK" pattern let's convert
them too.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
| -rw-r--r-- | t/test-lib-functions.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 6c9c61c79c..a027f0c409 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -562,9 +562,15 @@ write_script () { # Overwrite an existing <hook-name>, if it exists. Implies # --setup (i.e. the "test_when_finished" is assumed to have been # set up already). +# --disable +# Disable (chmod -x) an existing <hook-name>, which must exist. +# --remove +# Remove (rm -f) an existing <hook-name>, which must exist. test_hook () { setup= && clobber= && + disable= && + remove= && indir= && while test $# != 0 do @@ -579,6 +585,12 @@ test_hook () { --clobber) clobber=t ;; + --disable) + disable=t + ;; + --remove) + remove=t + ;; -*) BUG "invalid argument: $1" ;; @@ -592,6 +604,18 @@ test_hook () { git_dir=$(git -C "$indir" rev-parse --absolute-git-dir) && hook_dir="$git_dir/hooks" && hook_file="$hook_dir/$1" && + if test -n "$disable$remove" + then + test_path_is_file "$hook_file" && + if test -n "$disable" + then + chmod -x "$hook_file" + elif test -n "$remove" + then + rm -f "$hook_file" + fi && + return 0 + fi && if test -z "$clobber" then test_path_is_missing "$hook_file" |
