Skip to content

Commit 62e2486

Browse files
avargitster
authored andcommitted
hook tests: turn exit code assertions into a loop
Amend a test added in 96e7225 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7da7f63 commit 62e2486

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

t/t1800-hook.sh

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,16 @@ test_expect_success 'git hook run: stdout and stderr both write to our stderr' '
5353
test_must_be_empty stdout.actual
5454
'
5555

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
8166

8267
test_expect_success 'git hook run arg u ments without -- is not allowed' '
8368
test_expect_code 129 git hook run test-hook arg u ments

0 commit comments

Comments
 (0)