]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib.sh: de-duplicate error() teardown code
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 14 Oct 2021 00:47:28 +0000 (02:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Oct 2021 16:54:54 +0000 (09:54 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index 8361b5c1c574ed031ec5aaac1332297055450e07..c610f09ddb1e746c8a785b1aa96b1a63c494c35d 100644 (file)
@@ -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_ () {