git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] Abstract test_create_repo out for use in tests.

From
Carl Worth <cworth@cworth.org>
Date
Feb 17, 2006, 21:33 UTC
Message-ID
<1140212006127-git-send-email-cworth@cworth.org>
In-Reply-To
<11402120042011-git-send-email-cworth@cworth.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
---
 t/test-lib.sh |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
6110a439c2b1962c6f128cdaac3a2ee8450ac22c
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7a58a86..66f62b9 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 <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
@@ -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"
-- 
1.2.0.gf6e8
Previous: Carl WorthNext: Carl Worth
Message 3 of 4 in “Making git-clone clean up when it fails”
  1. Carl WorthFeb 17, 2006
  2. 1/3 Trap exit to clean up created directory if clone fails.Carl Worth, Feb 17, 2006
  3. 2/3 Abstract test_create_repo out for use in tests.Carl Worth, Feb 17, 2006
  4. 3/3 New test to verify that when git-clone fails it cleans up the new directory.Carl Worth, Feb 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.