@matheusbsbs / matheus-bagliano / commits / eedf8f97e5
Fork 0

Abstract test_create_repo out for use in tests.

Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Carl Worth committed Feb 17, 2006 at 13:33 UTC eedf8f97e58bbf4717705900379f2d63134047f9
1 file changed +17 -6
t/test-lib.sh
+17 -6
@@ -149,6 +149,21 @@ test_expect_code () {
149 fi
150 }
151
152 +# Most tests can use the created repository, but some amy need to create more.
153 +# Usage: test_create_repo <directory>
154 +test_create_repo () {
155 + test "$#" = 1 ||
156 + error "bug in the test script: not 1 parameter to test-create-repo"
157 + owd=`pwd`
158 + repo="$1"
159 + mkdir "$repo"
160 + cd "$repo" || error "Cannot setup test environment"
161 + "$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ 2>/dev/null ||
162 + error "cannot run git init-db -- have you built things yet?"
163 + mv .git/hooks .git/hooks-disabled
164 + cd "$owd"
165 +}
166 +
167 test_done () {
168 trap - exit
169 case "$test_failure" in
@@ -196,9 +211,5 @@ test -d ../templates/blt || {
211 # Test repository
212 test=trash
213 rm -fr "$test"
199 -mkdir "$test"
200 -cd "$test" || error "Cannot setup test environment"
201 -"$GIT_EXEC_PATH/git" init-db --template=../../templates/blt/ 2>/dev/null ||
202 -error "cannot run git init-db -- have you built things yet?"
203 -
204 -mv .git/hooks .git/hooks-disabled
214 +test_create_repo $test
215 +cd "$test"