@@ -589,17 +589,33 @@ USER_TERM="$TERM"
589
589
TERM=dumb
590
590
export TERM USER_TERM
591
591
592
- error () {
593
- say_color error " error: $* "
592
+ _error_exit () {
594
593
finalize_junit_xml
595
594
GIT_EXIT_OK=t
596
595
exit 1
597
596
}
598
597
598
+ error () {
599
+ say_color error " error: $* "
600
+ _error_exit
601
+ }
602
+
599
603
BUG () {
600
604
error >&7 " bug in the test script: $* "
601
605
}
602
606
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
+
603
619
say () {
604
620
say_color info " $* "
605
621
}
@@ -608,9 +624,7 @@ if test -n "$HARNESS_ACTIVE"
608
624
then
609
625
if test " $verbose " = t || test -n " $verbose_only "
610
626
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'
614
628
fi
615
629
fi
616
630
@@ -720,7 +734,7 @@ test_failure_ () {
720
734
say_color error " not ok $test_count - $1 "
721
735
shift
722
736
printf ' %s\n' " $* " | sed -e ' s/^/# /'
723
- test " $immediate " = " " || { finalize_junit_xml ; GIT_EXIT_OK=t ; exit 1 ; }
737
+ test " $immediate " = " " || _error_exit
724
738
}
725
739
726
740
test_known_broken_ok_ () {
@@ -1398,7 +1412,7 @@ then
1398
1412
fi
1399
1413
elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
1400
1414
then
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"
1402
1416
fi
1403
1417
1404
1418
# Last-minute variable setup
0 commit comments