Code

Add pack-refs and show-ref test cases.
[git.git] / t / test-lib.sh
index 43c8e55a8b5718fa4462f0b4cac07dd38c343d90..0fe2718845fa8ad66dfa850ac2921e33b10b51c1 100755 (executable)
@@ -9,6 +9,8 @@ LC_ALL=C
 PAGER=cat
 TZ=UTC
 export LANG LC_ALL PAGER TZ
+EDITOR=:
+VISUAL=:
 unset AUTHOR_DATE
 unset AUTHOR_EMAIL
 unset AUTHOR_NAME
@@ -30,6 +32,16 @@ unset SHA1_FILE_DIRECTORIES
 unset SHA1_FILE_DIRECTORY
 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
+export EDITOR VISUAL
+
+case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
+       1|2|true)
+               echo "* warning: Some tests will not work if GIT_TRACE" \
+                       "is set as to trace on STDERR ! *"
+               echo "* warning: Please set GIT_TRACE to something" \
+                       "other than 1, 2 or true ! *"
+               ;;
+esac
 
 # Each test should start with something like this, after copyright notices:
 #
@@ -151,6 +163,21 @@ test_expect_code () {
        fi
 }
 
+# Most tests can use the created repository, but some amy need to create more.
+# Usage: test_create_repo <directory>
+test_create_repo () {
+       test "$#" = 1 ||
+       error "bug in the test script: not 1 parameter to test-create-repo"
+       owd=`pwd`
+       repo="$1"
+       mkdir "$repo"
+       cd "$repo" || error "Cannot setup test environment"
+       "$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ 2>/dev/null ||
+       error "cannot run git init-db -- have you built things yet?"
+       mv .git/hooks .git/hooks-disabled
+       cd "$owd"
+}
+       
 test_done () {
        trap - exit
        case "$test_failure" in
@@ -184,7 +211,7 @@ export PATH GIT_EXEC_PATH
 PYTHON=`sed -e '1{
        s/^#!//
        q
-}' ../git-merge-recursive` || {
+}' ../git-merge-recursive-old` || {
        error "You haven't built things yet, have you?"
 }
 "$PYTHON" -c 'import subprocess' 2>/dev/null || {
@@ -198,9 +225,5 @@ test -d ../templates/blt || {
 # Test repository
 test=trash
 rm -fr "$test"
-mkdir "$test"
-cd "$test" || error "Cannot setup test environment"
-"$GIT_EXEC_PATH/git" init-db --template=../../templates/blt/ 2>/dev/null ||
-error "cannot run git init-db -- have you built things yet?"
-
-mv .git/hooks .git/hooks-disabled
+test_create_repo $test
+cd "$test"