@@ -716,6 +716,64 @@ perl () {
716716 command " $PERL_PATH " " $@ "
717717}
718718
719+ # Is the value one of the various ways to spell a boolean true/false?
720+ test_normalize_bool () {
721+ git -c magic.variable=" $1 " config --bool magic.variable 2> /dev/null
722+ }
723+
724+ # Given a variable $1, normalize the value of it to one of "true",
725+ # "false", or "auto" and store the result to it.
726+ #
727+ # test_tristate GIT_TEST_HTTPD
728+ #
729+ # A variable set to an empty string is set to 'false'.
730+ # A variable set to 'false' or 'auto' keeps its value.
731+ # Anything else is set to 'true'.
732+ # An unset variable defaults to 'auto'.
733+ #
734+ # The last rule is to allow people to set the variable to an empty
735+ # string and export it to decline testing the particular feature
736+ # for versions both before and after this change. We used to treat
737+ # both unset and empty variable as a signal for "do not test" and
738+ # took any non-empty string as "please test".
739+
740+ test_tristate () {
741+ if eval " test x\"\$ {$1 +isset}\" = xisset"
742+ then
743+ # explicitly set
744+ eval "
745+ case \"\$ $1 \" in
746+ '') $1 =false ;;
747+ auto) ;;
748+ *) $1 =\$ (test_normalize_bool \$ $1 || echo true) ;;
749+ esac
750+ "
751+ else
752+ eval " $1 =auto"
753+ fi
754+ }
755+
756+ # Exit the test suite, either by skipping all remaining tests or by
757+ # exiting with an error. If "$1" is "auto", we then we assume we were
758+ # opportunistically trying to set up some tests and we skip. If it is
759+ # "true", then we report a failure.
760+ #
761+ # The error/skip message should be given by $2.
762+ #
763+ test_skip_or_die () {
764+ case " $1 " in
765+ auto)
766+ skip_all=$2
767+ test_done
768+ ;;
769+ true)
770+ error " $2 "
771+ ;;
772+ * )
773+ error " BUG: test tristate is '$1 ' (real error: $2 )"
774+ esac
775+ }
776+
719777# The following mingw_* functions obey POSIX shell syntax, but are actually
720778# bash scripts, and are meant to be used only with bash on Windows.
721779
0 commit comments