X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=t%2Ftest-lib.sh;h=05f6e79560ff7e3d92c47221b3ee7adec098e676;hb=5892fc6504dd23d7cf9415afb13bae8a61d6c70e;hp=43c8e55a8b5718fa4462f0b4cac07dd38c343d90;hpb=abb7c7b31c0896bd838bbb6437b310db5a42227a;p=git.git diff --git a/t/test-lib.sh b/t/test-lib.sh index 43c8e55a..05f6e795 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -151,6 +151,21 @@ test_expect_code () { fi } +# Most tests can use the created repository, but some amy need to create more. +# Usage: test_create_repo +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 @@ -198,9 +213,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"