summaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-15 17:39:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-15 17:39:46 (GMT)
commit285907901c386eae4e0d50c617e1b82a58cff778 (patch)
treefa6d38cedf02f58d3f034fe818039ff122532c74 /t/test-lib.sh
parentf346fcb62a09b3518c291c5ab4449b0b10450acf (diff)
parenta6714088e0c03cf9e5820d54d4f9f3aece8af2e1 (diff)
downloadgit-285907901c386eae4e0d50c617e1b82a58cff778.zip
git-285907901c386eae4e0d50c617e1b82a58cff778.tar.gz
git-285907901c386eae4e0d50c617e1b82a58cff778.tar.bz2
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
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 57efcc5..b265c0a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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