mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
Merge branch 'fs/test-prereq'
The test framework learns to list unsatisfied test prerequisites, and optionally error out when prerequisites that are expected to be satisfied are not. * fs/test-prereq: test-lib: make BAIL_OUT() work in tests and prereq test-lib: introduce required prereq for test runs test-lib: show missing prereq summary
This commit is contained in:
commit
285907901c
6
t/README
6
t/README
|
@ -466,6 +466,12 @@ explicitly providing repositories when accessing submodule objects is
|
|||
complete or needs to be abandoned for whatever reason (in which case the
|
||||
migrated codepaths still retain their performance benefits).
|
||||
|
||||
GIT_TEST_REQUIRE_PREREQ=<list> allows specifying a space speparated list of
|
||||
prereqs that are required to succeed. If a prereq in this list is triggered by
|
||||
a test and then fails then the whole test run will abort. This can help to make
|
||||
sure the expected tests are executed and not silently skipped when their
|
||||
dependency breaks or is simply not present in a new environment.
|
||||
|
||||
Naming Tests
|
||||
------------
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ success=0
|
|||
failed=0
|
||||
broken=0
|
||||
total=0
|
||||
missing_prereq=
|
||||
|
||||
while read file
|
||||
do
|
||||
|
@ -30,10 +31,26 @@ do
|
|||
broken=$(($broken + $value)) ;;
|
||||
total)
|
||||
total=$(($total + $value)) ;;
|
||||
missing_prereq)
|
||||
missing_prereq="$missing_prereq,$value" ;;
|
||||
esac
|
||||
done <"$file"
|
||||
done
|
||||
|
||||
if test -n "$missing_prereq"
|
||||
then
|
||||
unique_missing_prereq=$(
|
||||
echo $missing_prereq |
|
||||
tr -s "," "\n" |
|
||||
grep -v '^$' |
|
||||
sort -u |
|
||||
paste -s -d ' ')
|
||||
if test -n "$unique_missing_prereq"
|
||||
then
|
||||
printf "\nmissing prereq: $unique_missing_prereq\n\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$failed_tests"
|
||||
then
|
||||
printf "\nfailed test(s):$failed_tests\n\n"
|
||||
|
|
|
@ -680,6 +680,17 @@ test_have_prereq () {
|
|||
# Keep a list of missing prerequisites; restore
|
||||
# the negative marker if necessary.
|
||||
prerequisite=${negative_prereq:+!}$prerequisite
|
||||
|
||||
# Abort if this prereq was marked as required
|
||||
if test -n "$GIT_TEST_REQUIRE_PREREQ"
|
||||
then
|
||||
case " $GIT_TEST_REQUIRE_PREREQ " in
|
||||
*" $prerequisite "*)
|
||||
BAIL_OUT "required prereq $prerequisite failed"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test -z "$missing_prereq"
|
||||
then
|
||||
missing_prereq=$prerequisite
|
||||
|
|
|
@ -589,6 +589,15 @@ USER_TERM="$TERM"
|
|||
TERM=dumb
|
||||
export TERM USER_TERM
|
||||
|
||||
# What is written by tests to stdout and stderr is sent to different places
|
||||
# depending on the test mode (e.g. /dev/null in non-verbose mode, piped to tee
|
||||
# with --tee option, etc.). We save the original stdin to FD #6 and stdout and
|
||||
# stderr to #5 and #7, so that the test framework can use them (e.g. for
|
||||
# printing errors within the test framework) independently of the test mode.
|
||||
exec 5>&1
|
||||
exec 6<&0
|
||||
exec 7>&2
|
||||
|
||||
_error_exit () {
|
||||
finalize_junit_xml
|
||||
GIT_EXIT_OK=t
|
||||
|
@ -612,7 +621,7 @@ BAIL_OUT () {
|
|||
local bail_out="Bail out! "
|
||||
local message="$1"
|
||||
|
||||
say_color error $bail_out "$message"
|
||||
say_color >&5 error $bail_out "$message"
|
||||
_error_exit
|
||||
}
|
||||
|
||||
|
@ -637,9 +646,6 @@ then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
exec 5>&1
|
||||
exec 6<&0
|
||||
exec 7>&2
|
||||
if test "$verbose_log" = "t"
|
||||
then
|
||||
exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3
|
||||
|
@ -669,6 +675,8 @@ test_fixed=0
|
|||
test_broken=0
|
||||
test_success=0
|
||||
|
||||
test_missing_prereq=
|
||||
|
||||
test_external_has_tap=0
|
||||
|
||||
die () {
|
||||
|
@ -1069,6 +1077,14 @@ test_skip () {
|
|||
of_prereq=" of $test_prereq"
|
||||
fi
|
||||
skipped_reason="missing $missing_prereq${of_prereq}"
|
||||
|
||||
# Keep a list of all the missing prereq for result aggregation
|
||||
if test -z "$missing_prereq"
|
||||
then
|
||||
test_missing_prereq=$missing_prereq
|
||||
else
|
||||
test_missing_prereq="$test_missing_prereq,$missing_prereq"
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$to_skip" in
|
||||
|
@ -1175,6 +1191,7 @@ test_done () {
|
|||
fixed $test_fixed
|
||||
broken $test_broken
|
||||
failed $test_failure
|
||||
missing_prereq $test_missing_prereq
|
||||
|
||||
EOF
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue