Merge branch 'np/log-graph-octopus-fix'
[gitweb.git] / t / test-lib.sh
index 78f7097746fc88f1de5321e5f78d9aec8c5e0b5f..897e6fcc94a195bd8b4493deee411ba9c6ba9f15 100644 (file)
@@ -134,9 +134,40 @@ export EDITOR
 GIT_TRACE_BARE=1
 export GIT_TRACE_BARE
 
-if test -n "${TEST_GIT_INDEX_VERSION:+isset}"
+check_var_migration () {
+       # the warnings and hints given from this helper depends
+       # on end-user settings, which will disrupt the self-test
+       # done on the test framework itself.
+       case "$GIT_TEST_FRAMEWORK_SELFTEST" in
+       t)      return ;;
+       esac
+
+       old_name=$1 new_name=$2
+       eval "old_isset=\${${old_name}:+isset}"
+       eval "new_isset=\${${new_name}:+isset}"
+
+       case "$old_isset,$new_isset" in
+       isset,)
+               echo >&2 "warning: $old_name is now $new_name"
+               echo >&2 "hint: set $new_name too during the transition period"
+               eval "$new_name=\$$old_name"
+               ;;
+       isset,isset)
+               # do this later
+               # echo >&2 "warning: $old_name is now $new_name"
+               # echo >&2 "hint: remove $old_name"
+               ;;
+       esac
+}
+
+check_var_migration GIT_FSMONITOR_TEST GIT_TEST_FSMONITOR
+check_var_migration TEST_GIT_INDEX_VERSION GIT_TEST_INDEX_VERSION
+check_var_migration GIT_FORCE_PRELOAD_TEST GIT_TEST_PRELOAD_INDEX
+
+# Use specific version of the index file format
+if test -n "${GIT_TEST_INDEX_VERSION:+isset}"
 then
-       GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION"
+       GIT_INDEX_VERSION="$GIT_TEST_INDEX_VERSION"
        export GIT_INDEX_VERSION
 fi
 
@@ -867,7 +898,7 @@ then
                # handle only executables, unless they are shell libraries that
                # need to be in the exec-path.
                test -x "$1" ||
-               test "# " = "$(head -c 2 <"$1")" ||
+               test "# " = "$(test_copy_bytes 2 <"$1")" ||
                return;
 
                base=$(basename "$1")
@@ -882,7 +913,7 @@ then
                # do not override scripts
                if test -x "$symlink_target" &&
                    test ! -d "$symlink_target" &&
-                   test "#!" != "$(head -c 2 < "$symlink_target")"
+                   test "#!" != "$(test_copy_bytes 2 <"$symlink_target")"
                then
                        symlink_target=../valgrind.sh
                fi
@@ -1083,6 +1114,12 @@ else
        test_set_prereq C_LOCALE_OUTPUT
 fi
 
+if test -z "$GIT_TEST_CHECK_CACHE_TREE"
+then
+       GIT_TEST_CHECK_CACHE_TREE=true
+       export GIT_TEST_CHECK_CACHE_TREE
+fi
+
 test_lazy_prereq PIPE '
        # test whether the filesystem supports FIFOs
        test_have_prereq !MINGW,!CYGWIN &&
@@ -1104,6 +1141,20 @@ test_lazy_prereq CASE_INSENSITIVE_FS '
        test "$(cat CamelCase)" != good
 '
 
+test_lazy_prereq FUNNYNAMES '
+       test_have_prereq !MINGW &&
+       touch -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+embedded" 2>/dev/null &&
+       rm -- \
+               "FUNNYNAMES tab embedded" \
+               "FUNNYNAMES \"quote embedded\"" \
+               "FUNNYNAMES newline
+embedded" 2>/dev/null
+'
+
 test_lazy_prereq UTF8_NFD_TO_NFC '
        # check whether FS converts nfd unicode to nfc
        auml=$(printf "\303\244")