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>

Ævar Arnfjörð Bjarmason committed Mar 17, 2022 at 11:13 UTC 62e2486b614917e4ba578b0758fd126ce107663c
1 file changed +10 -25
t/t1800-hook.sh
+10 -25
@@ -53,31 +53,16 @@ test_expect_success 'git hook run: stdout and stderr both write to our stderr' '
53 test_must_be_empty stdout.actual
54 '
55
56 -test_expect_success 'git hook run: exit codes are passed along' '
57 - write_script .git/hooks/test-hook <<-EOF &&
58 - exit 1
59 - EOF
60 -
61 - test_expect_code 1 git hook run test-hook &&
62 -
63 - write_script .git/hooks/test-hook <<-EOF &&
64 - exit 2
65 - EOF
66 -
67 - test_expect_code 2 git hook run test-hook &&
68 -
69 - write_script .git/hooks/test-hook <<-EOF &&
70 - exit 128
71 - EOF
72 -
73 - test_expect_code 128 git hook run test-hook &&
74 -
75 - write_script .git/hooks/test-hook <<-EOF &&
76 - exit 129
77 - EOF
78 -
79 - test_expect_code 129 git hook run test-hook
80 -'
56 +for code in 1 2 128 129
57 +do
58 + test_expect_success "git hook run: exit code $code is passed along" '
59 + test_hook test-hook <<-EOF &&
60 + exit $code
61 + EOF
62 +
63 + test_expect_code $code git hook run test-hook
64 + '
65 +done
66
67 test_expect_success 'git hook run arg u ments without -- is not allowed' '
68 test_expect_code 129 git hook run test-hook arg u ments