summaryrefslogtreecommitdiff
path: root/t/t1800-hook.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-03-30 18:01:11 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-03-30 18:01:11 -0700
commita5bf611cc4f14f062cd74965deafe617048bff05 (patch)
tree47dd4d166bf8dc324a619d591ad03b918a93211a /t/t1800-hook.sh
parentMerge branch 'jd/prompt-upstream-mark' (diff)
parenthttp tests: use "test_hook" for "smart" and "dumb" http tests (diff)
downloadtgif-a5bf611cc4f14f062cd74965deafe617048bff05.tar.xz
Merge branch 'ab/hook-tests-updates'
Update tests around the use of hook scripts. * ab/hook-tests-updates: http tests: use "test_hook" for "smart" and "dumb" http tests proc-receive hook tests: use "test_hook" instead of "write_script" tests: extend "test_hook" for "rm" and "chmod -x", convert "$HOOK" tests: use "test_hook" for misc "mkdir -p" and "chmod" cases tests: change "mkdir -p && write_script" to use "test_hook" tests: change "cat && chmod +x" to use "test_hook" gc + p4 tests: use "test_hook", remove sub-shells fetch+push tests: use "test_hook" and "test_when_finished" pattern bugreport tests: tighten up "git bugreport -s hooks" test tests: assume the hooks are disabled by default http tests: don't rely on "hook/post-update.sample" hook tests: turn exit code assertions into a loop test-lib-functions: add and use a "test_hook" wrapper
Diffstat (limited to 't/t1800-hook.sh')
-rwxr-xr-xt/t1800-hook.sh45
1 files changed, 17 insertions, 28 deletions
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 29718aa991..26ed5e11bc 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -27,7 +27,7 @@ test_expect_success 'git hook run: nonexistent hook with --ignore-missing' '
'
test_expect_success 'git hook run: basic' '
- write_script .git/hooks/test-hook <<-EOF &&
+ test_hook test-hook <<-EOF &&
echo Test hook
EOF
@@ -39,7 +39,7 @@ test_expect_success 'git hook run: basic' '
'
test_expect_success 'git hook run: stdout and stderr both write to our stderr' '
- write_script .git/hooks/test-hook <<-EOF &&
+ test_hook test-hook <<-EOF &&
echo >&1 Will end up on stderr
echo >&2 Will end up on stderr
EOF
@@ -53,38 +53,23 @@ test_expect_success 'git hook run: stdout and stderr both write to our stderr' '
test_must_be_empty stdout.actual
'
-test_expect_success 'git hook run: exit codes are passed along' '
- write_script .git/hooks/test-hook <<-EOF &&
- exit 1
- EOF
-
- test_expect_code 1 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 2
- EOF
-
- test_expect_code 2 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 128
- EOF
+for code in 1 2 128 129
+do
+ test_expect_success "git hook run: exit code $code is passed along" '
+ test_hook test-hook <<-EOF &&
+ exit $code
+ EOF
- test_expect_code 128 git hook run test-hook &&
-
- write_script .git/hooks/test-hook <<-EOF &&
- exit 129
- EOF
-
- test_expect_code 129 git hook run test-hook
-'
+ test_expect_code $code git hook run test-hook
+ '
+done
test_expect_success 'git hook run arg u ments without -- is not allowed' '
test_expect_code 129 git hook run test-hook arg u ments
'
test_expect_success 'git hook run -- pass arguments' '
- write_script .git/hooks/test-hook <<-\EOF &&
+ test_hook test-hook <<-\EOF &&
echo $1
echo $2
EOF
@@ -99,7 +84,7 @@ test_expect_success 'git hook run -- pass arguments' '
'
test_expect_success 'git hook run -- out-of-repo runs excluded' '
- write_script .git/hooks/test-hook <<-EOF &&
+ test_hook test-hook <<-EOF &&
echo Test hook
EOF
@@ -120,6 +105,10 @@ test_expect_success 'git -c core.hooksPath=<PATH> hook run' '
Hook ran four
EOF
+ test_hook test-hook <<-EOF &&
+ echo Test hook
+ EOF
+
# Test various ways of specifying the path. See also
# t1350-config-hooks-path.sh
>actual &&