test-lib: allow setting the index format version
[gitweb.git] / t / test-lib-functions.sh
index f98769427b51017db7b9d757fd12e582609dbb03..0bf1e63ab5021349ae0b625e2ea3daf80b6d80b6 100644 (file)
@@ -1,4 +1,5 @@
-#!/bin/sh
+# Library of functions shared by all tests scripts, included by
+# test-lib.sh.
 #
 # Copyright (c) 2005 Junio C Hamano
 #
@@ -31,6 +32,11 @@ test_set_editor () {
        export EDITOR
 }
 
+test_set_index_version () {
+    GIT_INDEX_VERSION="$1"
+    export GIT_INDEX_VERSION
+}
+
 test_decode_color () {
        awk '
                function name(n) {
@@ -76,11 +82,11 @@ test_decode_color () {
 }
 
 nul_to_q () {
-       "$PERL_PATH" -pe 'y/\000/Q/'
+       perl -pe 'y/\000/Q/'
 }
 
 q_to_nul () {
-       "$PERL_PATH" -pe 'y/Q/\000/'
+       perl -pe 'y/Q/\000/'
 }
 
 q_to_cr () {
@@ -648,7 +654,7 @@ test_seq () {
        2)      ;;
        *)      error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
        esac
-       "$PERL_PATH" -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
+       perl -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
 }
 
 # This function can be used to schedule some commands to be run
@@ -711,6 +717,10 @@ test_ln_s_add () {
        fi
 }
 
+perl () {
+       command "$PERL_PATH" "$@"
+}
+
 # The following mingw_* functions obey POSIX shell syntax, but are actually
 # bash scripts, and are meant to be used only with bash on Windows.