Subject: Re: [PATCH 01/10] hook tests: turn exit code assertions into a loop

From: Junio C Hamano <[email-masked]>
Date: Wed, 02 Mar 2022 12:55:03 -0800

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> 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 <[email-masked]>
> ---
>  t/t1800-hook.sh | 35 ++++++++++-------------------------
>  1 file changed, 10 insertions(+), 25 deletions(-)
> ...
> +for code in 1 2 128 129
> +do
> +	test_expect_success "git hook run: exit code $code is passed along" '
> +		write_script .git/hooks/test-hook <<-EOF &&
> +		exit $code
> +		EOF
> +
> +		test_expect_code $code git hook run test-hook
> +	'
> +done

Looks good.  Each being separate test_expect_success means we do not
have to worry about breaking out of the loop upon a failure, which
is much cleaner than I would have thought ;-)

It also illustrates a good use of unquoted here document.