Re: [PATCH 01/10] hook tests: turn exit code assertions into a loop
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 2, 2022, 20:55 UTC
- Message-ID
- <xmqqlexsjcrc.fsf@gitster.g>
- In-Reply-To
- <patch-01.10-706460d10b9-20220302T131859Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 19 quoted lines
> 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> > --- > 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.