git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carl Worth <cworth@cworth.org>
To: git@vger.kernel.org
Cc: Carl Worth <cworth@cworth.org>
Subject: [PATCH 2/3] Abstract test_create_repo out for use in tests.
Date: Fri, 17 Feb 2006 13:33:26 -0800	[thread overview]
Message-ID: <1140212006127-git-send-email-cworth@cworth.org> (raw)
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

  reply	other threads:[~2006-02-17 21:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 21:33 Making git-clone clean up when it fails Carl Worth
2006-02-17 21:33 ` [PATCH 1/3] Trap exit to clean up created directory if clone fails Carl Worth
2006-02-17 21:33   ` Carl Worth [this message]
2006-02-17 21:33     ` [PATCH 3/3] New test to verify that when git-clone fails it cleans up the new directory Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1140212006127-git-send-email-cworth@cworth.org \
    --to=cworth@cworth.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).