]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/test-lib-functions.sh
tests: replace test_tristate with "git env--helper"
[thirdparty/git.git] / t / test-lib-functions.sh
index 0367cec5fde0514274fbd322bce0a58e1438b3e8..527508c350e2b157719fd509dce0f5111616ef4c 100644 (file)
@@ -1035,62 +1035,20 @@ perl () {
        command "$PERL_PATH" "$@" 2>&7
 } 7>&2 2>&4
 
-# Is the value one of the various ways to spell a boolean true/false?
-test_normalize_bool () {
-       git -c magic.variable="$1" config --bool magic.variable 2>/dev/null
-}
-
-# Given a variable $1, normalize the value of it to one of "true",
-# "false", or "auto" and store the result to it.
-#
-#     test_tristate GIT_TEST_HTTPD
-#
-# A variable set to an empty string is set to 'false'.
-# A variable set to 'false' or 'auto' keeps its value.
-# Anything else is set to 'true'.
-# An unset variable defaults to 'auto'.
-#
-# The last rule is to allow people to set the variable to an empty
-# string and export it to decline testing the particular feature
-# for versions both before and after this change.  We used to treat
-# both unset and empty variable as a signal for "do not test" and
-# took any non-empty string as "please test".
-
-test_tristate () {
-       if eval "test x\"\${$1+isset}\" = xisset"
-       then
-               # explicitly set
-               eval "
-                       case \"\$$1\" in
-                       '')     $1=false ;;
-                       auto)   ;;
-                       *)      $1=\$(test_normalize_bool \$$1 || echo true) ;;
-                       esac
-               "
-       else
-               eval "$1=auto"
-       fi
-}
-
 # Exit the test suite, either by skipping all remaining tests or by
-# exiting with an error. If "$1" is "auto", we then we assume we were
-# opportunistically trying to set up some tests and we skip. If it is
-# "true", then we report a failure.
+# exiting with an error. If our prerequisite variable $1 falls back
+# on a default assume we were opportunistically trying to set up some
+# tests and we skip. If it is explicitly "true", then we report a failure.
 #
 # The error/skip message should be given by $2.
 #
 test_skip_or_die () {
-       case "$1" in
-       auto)
+       if ! git env--helper --mode-bool --variable=$1 --default=0 --exit-code --quiet
+       then
                skip_all=$2
                test_done
-               ;;
-       true)
-               error "$2"
-               ;;
-       *)
-               error "BUG: test tristate is '$1' (real error: $2)"
-       esac
+       fi
+       error "$2"
 }
 
 # The following mingw_* functions obey POSIX shell syntax, but are actually