From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH 1/2] test-lib.sh: de-duplicate error() teardown code
Date: Thu, 14 Oct 2021 09:26:52 -0700 [thread overview]
Message-ID: <xmqqzgrbd12r.fsf@gitster.g> (raw)
In-Reply-To: <patch-1.2-d4c67829076-20211014T004542Z-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Thu, 14 Oct 2021 02:47:28 +0200")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> De-duplicate the "finalize_junit_xml; GIT_EXIT_OK=t; exit 1" code
> shared between the "error()" and "--immediate on failure" code paths,
> in preparation for adding a third user in a subsequent commit.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> t/test-lib.sh | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Nice. I do recall seeing the duplication when these finalize-junit
calls were introduced and thought about marking it as a leftover
clean-up candidate. Nice to see it done here.
Thanks.
>
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 8361b5c1c57..c610f09ddb1 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -589,13 +589,17 @@ USER_TERM="$TERM"
> TERM=dumb
> export TERM USER_TERM
>
> -error () {
> - say_color error "error: $*"
> +_error_exit () {
> finalize_junit_xml
> GIT_EXIT_OK=t
> exit 1
> }
>
> +error () {
> + say_color error "error: $*"
> + _error_exit
> +}
> +
> BUG () {
> error >&7 "bug in the test script: $*"
> }
> @@ -720,7 +724,7 @@ test_failure_ () {
> say_color error "not ok $test_count - $1"
> shift
> printf '%s\n' "$*" | sed -e 's/^/# /'
> - test "$immediate" = "" || { finalize_junit_xml; GIT_EXIT_OK=t; exit 1; }
> + test "$immediate" = "" || _error_exit
> }
>
> test_known_broken_ok_ () {
next prev parent reply other threads:[~2021-10-14 16:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 0:47 [PATCH 0/2] test-lib.sh: add BAIL_OUT function, use it for SANITIZE=leak Ævar Arnfjörð Bjarmason
2021-10-14 0:47 ` [PATCH 1/2] test-lib.sh: de-duplicate error() teardown code Ævar Arnfjörð Bjarmason
2021-10-14 16:26 ` Junio C Hamano [this message]
2021-10-14 0:47 ` [PATCH 2/2] test-lib.sh: use "Bail out!" syntax on bad SANITIZE=leak use Ævar Arnfjörð Bjarmason
2021-10-14 16:39 ` Junio C Hamano
2021-10-14 17:25 ` Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzgrbd12r.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.