@@ -589,17 +589,33 @@ USER_TERM="$TERM"
589589TERM=dumb
590590export TERM USER_TERM
591591
592- error () {
593- say_color error " error: $* "
592+ _error_exit () {
594593 finalize_junit_xml
595594 GIT_EXIT_OK=t
596595 exit 1
597596}
598597
598+ error () {
599+ say_color error " error: $* "
600+ _error_exit
601+ }
602+
599603BUG () {
600604 error >&7 " bug in the test script: $* "
601605}
602606
607+ BAIL_OUT () {
608+ test $# -ne 1 && BUG " 1 param"
609+
610+ # Do not change "Bail out! " string. It's part of TAP syntax:
611+ # https://testanything.org/tap-specification.html
612+ local bail_out=" Bail out! "
613+ local message=" $1 "
614+
615+ say_color error $bail_out " $message "
616+ _error_exit
617+ }
618+
603619say () {
604620 say_color info " $* "
605621}
@@ -608,9 +624,7 @@ if test -n "$HARNESS_ACTIVE"
608624then
609625 if test " $verbose " = t || test -n " $verbose_only "
610626 then
611- printf ' Bail out! %s\n' \
612- ' verbose mode forbidden under TAP harness; try --verbose-log'
613- exit 1
627+ BAIL_OUT ' verbose mode forbidden under TAP harness; try --verbose-log'
614628 fi
615629fi
616630
@@ -720,7 +734,7 @@ test_failure_ () {
720734 say_color error " not ok $test_count - $1 "
721735 shift
722736 printf ' %s\n' " $* " | sed -e ' s/^/# /'
723- test " $immediate " = " " || { finalize_junit_xml ; GIT_EXIT_OK=t ; exit 1 ; }
737+ test " $immediate " = " " || _error_exit
724738}
725739
726740test_known_broken_ok_ () {
@@ -1398,7 +1412,7 @@ then
13981412 fi
13991413elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
14001414then
1401- error " GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak"
1415+ BAIL_OUT " GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak"
14021416fi
14031417
14041418# Last-minute variable setup
0 commit comments