Merge branch 'ab/test-bail'
A new feature has been added to abort early in the test framework. * ab/test-bail: test-lib.sh: use "Bail out!" syntax on bad SANITIZE=leak use test-lib.sh: de-duplicate error() teardown code
This commit is contained in:
@ -589,17 +589,33 @@ USER_TERM="$TERM"
|
|||||||
TERM=dumb
|
TERM=dumb
|
||||||
export TERM USER_TERM
|
export TERM USER_TERM
|
||||||
|
|
||||||
error () {
|
_error_exit () {
|
||||||
say_color error "error: $*"
|
|
||||||
finalize_junit_xml
|
finalize_junit_xml
|
||||||
GIT_EXIT_OK=t
|
GIT_EXIT_OK=t
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error () {
|
||||||
|
say_color error "error: $*"
|
||||||
|
_error_exit
|
||||||
|
}
|
||||||
|
|
||||||
BUG () {
|
BUG () {
|
||||||
error >&7 "bug in the test script: $*"
|
error >&7 "bug in the test script: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BAIL_OUT () {
|
||||||
|
test $# -ne 1 && BUG "1 param"
|
||||||
|
|
||||||
|
# Do not change "Bail out! " string. It's part of TAP syntax:
|
||||||
|
# https://testanything.org/tap-specification.html
|
||||||
|
local bail_out="Bail out! "
|
||||||
|
local message="$1"
|
||||||
|
|
||||||
|
say_color error $bail_out "$message"
|
||||||
|
_error_exit
|
||||||
|
}
|
||||||
|
|
||||||
say () {
|
say () {
|
||||||
say_color info "$*"
|
say_color info "$*"
|
||||||
}
|
}
|
||||||
@ -608,9 +624,7 @@ if test -n "$HARNESS_ACTIVE"
|
|||||||
then
|
then
|
||||||
if test "$verbose" = t || test -n "$verbose_only"
|
if test "$verbose" = t || test -n "$verbose_only"
|
||||||
then
|
then
|
||||||
printf 'Bail out! %s\n' \
|
BAIL_OUT 'verbose mode forbidden under TAP harness; try --verbose-log'
|
||||||
'verbose mode forbidden under TAP harness; try --verbose-log'
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -720,7 +734,7 @@ test_failure_ () {
|
|||||||
say_color error "not ok $test_count - $1"
|
say_color error "not ok $test_count - $1"
|
||||||
shift
|
shift
|
||||||
printf '%s\n' "$*" | sed -e 's/^/# /'
|
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_ () {
|
test_known_broken_ok_ () {
|
||||||
@ -1398,7 +1412,7 @@ then
|
|||||||
fi
|
fi
|
||||||
elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
|
elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false
|
||||||
then
|
then
|
||||||
error "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak"
|
BAIL_OUT "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Last-minute variable setup
|
# Last-minute variable setup
|
||||||
|
Reference in New Issue
Block a user