test-lib.sh: de-duplicate error() teardown code

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>

Ævar Arnfjörð Bjarmason committed Oct 14, 2021 at 02:47 UTC 8583bf75591398fff3c0ef44eb59cd23b4565298
1 file changed +7 -3
t/test-lib.sh
+7 -3
@@ -589,13 +589,17 @@ USER_TERM="$TERM"
589 TERM=dumb
590 export TERM USER_TERM
591
592 -error () {
593 - say_color error "error: $*"
592 +_error_exit () {
593 finalize_junit_xml
594 GIT_EXIT_OK=t
595 exit 1
596 }
597
598 +error () {
599 + say_color error "error: $*"
600 + _error_exit
601 +}
602 +
603 BUG () {
604 error >&7 "bug in the test script: $*"
605 }
@@ -720,7 +724,7 @@ test_failure_ () {
724 say_color error "not ok $test_count - $1"
725 shift
726 printf '%s\n' "$*" | sed -e 's/^/# /'
723 - test "$immediate" = "" || { finalize_junit_xml; GIT_EXIT_OK=t; exit 1; }
727 + test "$immediate" = "" || _error_exit
728 }
729
730 test_known_broken_ok_ () {