X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=t%2Ftest-lib.sh;h=66f62b9c6f2a31965c856fc9b7d056a86abbcfbc;hb=8cd52c3ca9c865891d8f15db08af324aadb7b913;hp=7a58a86f967fdb114bb980a631292da2cee2a352;hpb=69c57a8d87c0e1db40c6afbaa71769e68009e6a4;p=git.git diff --git a/t/test-lib.sh b/t/test-lib.sh index 7a58a86f..66f62b9c 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -149,6 +149,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 @@ -196,9 +211,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"