summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-03-17 11:13:07 +0100
committerJunio C Hamano <gitster@pobox.com>2022-03-17 08:40:26 -0700
commit62e2486b614917e4ba578b0758fd126ce107663c (patch)
tree6b3e35a571b0117f998eafd37d85df06c4778226
parent7da7f63cf9950d0ecd83579b4ca28f7b2805bf32 (diff)
downloadgit-62e2486b614917e4ba578b0758fd126ce107663c.tar.gz
hook tests: turn exit code assertions into a loop
Amend a test added in 96e7225b310 (hook: add 'run' subcommand, 2021-12-22) to use a for-loop instead of a copy/pasting the same test for the four exit codes we test. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t1800-hook.sh35
1 files changed, 10 insertions, 25 deletions
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 93540b1fa1..26ed5e11bc 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -53,31 +53,16 @@ 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
-
- 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
-'
+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 $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