Re: [PATCH v2 3/5] tests: turn GPG, GPGSM and RFC1991 into lazy prereqs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 27, 2020, 21:37 UTC
- Message-ID
- <xmqq1rpdfpj5.fsf@gitster.c.googlers.com>
- In-Reply-To
- <CAPig+cT6CQsYyMR=-nAo7GD8mXAWyUWPrbTnCZ0nBs54Ah0PbQ@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 24 quoted lines
> On Fri, Mar 27, 2020 at 1:44 PM Junio C Hamano <gitster@pobox.com> wrote: >> Subject: [PATCH] t/README: suggest how to leave test early with failure >> + test_expect_success 'git frotz on various versions' ' >> + for revision in one two three >> + do >> + echo "frotz $revision" >expect && >> + git frotz "$revision" >actual && >> + test_cmp expect actual || return 1 >> + done && >> + test something else >> + ' >> + >> + Note that this is only possible in our test suite, where we >> + arrange to run your test <script> wrapped inside a helper >> + function to ensure that return values matter; in your own script >> + outside any function, this technique may not work. >> + >> And here are the "don'ts:" >> >> - Don't exit() within a <script> part. > > We use 'exit 1' to terminate subshells[1] inside tests. > > [1]: https://lore.kernel.org/git/20150325052952.GE31924@peff.net/
Yeah, I gave two alternatives, but the third one could be
test_expect_success 'git frotz on various versions' '
(
for revision in one two three
do
echo "frotz $revision" >expect &&
git frotz "$revision" >actual &&
test_cmp expect actual || exit 1
done
) &&
test something else
'Anyway, that existing rule is not what I added in the rough draft under discussion. To clarify it, we'd end up needing "unless A, B or C" that may be too complex. I dunno.
Thanks.