All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Buchacher <drizzd@aon.at>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: Mark Lodato <lodatom@gmail.com>, git@vger.kernel.org
Subject: [PATCH] t5540: test both smart and dumb protocols
Date: Wed, 28 Oct 2009 18:52:26 +0100	[thread overview]
Message-ID: <20091028175226.GA10264@localhost> (raw)
In-Reply-To: <20091028001737.GN10505@spearce.org>


Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---

On Tue, Oct 27, 2009 at 05:17:38PM -0700, Shawn O. Pearce wrote:
> Clemens Buchacher <drizzd@aon.at> wrote:
> > Set LIB_HTTPD_GIT to enable smart HTTP tests.
> 
> My concern here is we have to run the test suite twice in order to
> test HTTP support.  We should only run it once, with GIT_TEST_HTTPD=1
> set and have it all run at once.

How about this? The original code is not touched except for the test
description.

Clemens

 t/lib-httpd.sh       |    2 +
 t/t5540-http-push.sh |  160 ++-----------------------------------------------
 t/test-http-push.sh  |  159 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 168 insertions(+), 153 deletions(-)
 create mode 100755 t/test-http-push.sh

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index aaa0a71..cf1f1df 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -121,4 +121,6 @@ stop_httpd() {
 
 	"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
 		-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
+
+	rm -f "$HTTPD_ROOT_PATH/modules"
 }
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
index 049e129..a156f37 100755
--- a/t/t5540-http-push.sh
+++ b/t/t5540-http-push.sh
@@ -1,155 +1,9 @@
 #!/bin/sh
-#
-# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
-#
 
-test_description='test http-push
-
-This test runs various sanity checks on http-push.'
-
-. ./test-lib.sh
-
-ROOT_PATH="$PWD"
-if test -z "$LIB_HTTPD_GIT"
-then
-	LIB_HTTPD_DAV=t
-fi
-LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
-
-if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
-then
-	say "skipping test, USE_CURL_MULTI is not defined"
-	test_done
-fi
-
-. "$TEST_DIRECTORY"/lib-httpd.sh
-start_httpd
-
-test_expect_success 'setup remote repository' '
-	cd "$ROOT_PATH" &&
-	mkdir test_repo &&
-	cd test_repo &&
-	git init &&
-	: >path1 &&
-	git add path1 &&
-	test_tick &&
-	git commit -m initial &&
-	cd - &&
-	git clone --bare test_repo test_repo.git &&
-	cd test_repo.git &&
-	ORIG_HEAD=$(git rev-parse --verify HEAD) &&
-	if test -n "$LIB_HTTPD_GIT"
-	then
-		git config http.receivepack true
-	else
-		git --bare update-server-info &&
-		mv hooks/post-update.sample hooks/post-update
-	fi &&
-	cd - &&
-	mv test_repo.git "$HTTPD_GIT_PATH"
-'
-
-test_expect_success 'clone remote repository' '
-	cd "$ROOT_PATH" &&
-	git clone $HTTPD_GIT_URL/test_repo.git test_repo_clone
-'
-
-test_expect_success 'push to remote repository with packed refs' '
-	cd "$ROOT_PATH"/test_repo_clone &&
-	: >path2 &&
-	git add path2 &&
-	test_tick &&
-	git commit -m path2 &&
-	HEAD=$(git rev-parse --verify HEAD) &&
-	git push &&
-	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
-	 test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'push already up-to-date' '
-	git push
-'
-
-test_expect_success 'push to remote repository with unpacked refs' '
-	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
-	 rm packed-refs &&
-	 git update-ref refs/heads/master $ORIG_HEAD &&
-	 git --bare update-server-info) &&
-	git push &&
-	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
-	 test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'http-push fetches unpacked objects' '
-	cp -R "$HTTPD_GIT_PATH"/test_repo.git \
-		"$HTTPD_GIT_PATH"/test_repo_unpacked.git &&
-
-	git clone $HTTPD_GIT_URL/test_repo_unpacked.git \
-		"$ROOT_PATH"/fetch_unpacked &&
-
-	# By reset, we force git to retrieve the object
-	(cd "$ROOT_PATH"/fetch_unpacked &&
-	 git reset --hard HEAD^ &&
-	 git remote rm origin &&
-	 git reflog expire --expire=0 --all &&
-	 git prune &&
-	 git push -f -v $HTTPD_GIT_URL/test_repo_unpacked.git master)
-'
-
-test_expect_success 'http-push fetches packed objects' '
-	cp -R "$HTTPD_GIT_PATH"/test_repo.git \
-		"$HTTPD_GIT_PATH"/test_repo_packed.git &&
-
-	git clone $HTTPD_GIT_URL/test_repo_packed.git \
-		"$ROOT_PATH"/test_repo_clone_packed &&
-
-	(cd "$HTTPD_GIT_PATH"/test_repo_packed.git &&
-	 git --bare repack &&
-	 git --bare prune-packed) &&
-
-	# By reset, we force git to retrieve the packed object
-	(cd "$ROOT_PATH"/test_repo_clone_packed &&
-	 git reset --hard HEAD^ &&
-	 git remote rm origin &&
-	 git reflog expire --expire=0 --all &&
-	 git prune &&
-	 git push -f -v $HTTPD_GIT_URL/test_repo_packed.git master)
-'
-
-test_expect_success 'create and delete remote branch' '
-	cd "$ROOT_PATH"/test_repo_clone &&
-	git checkout -b dev &&
-	: >path3 &&
-	git add path3 &&
-	test_tick &&
-	git commit -m dev &&
-	git push origin dev &&
-	git fetch &&
-	git push origin :dev &&
-	git fetch &&
-	test_must_fail git show-ref --verify refs/remotes/origin/dev
-'
-
-test -n "$LIB_HTTPD_GIT" ||
-test_expect_success 'MKCOL sends directory names with trailing slashes' '
-
-	! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
-
-'
-
-x1="[0-9a-f]"
-x2="$x1$x1"
-x5="$x1$x1$x1$x1$x1"
-x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
-x40="$x38$x2"
-
-test -n "$LIB_HTTPD_GIT" ||
-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
-	sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
-	grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
-
-'
-
-stop_httpd
-
-test_done
+LIB_HTTPD_GIT=t
+export LIB_HTTPD_GIT
+./test-http-push.sh $@
+sleep 1
+LIB_HTTPD_GIT=
+export LIB_HTTPD_GIT
+./test-http-push.sh $@
diff --git a/t/test-http-push.sh b/t/test-http-push.sh
new file mode 100755
index 0000000..c557541
--- /dev/null
+++ b/t/test-http-push.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+
+if test -n "$LIB_HTTPD_GIT"
+then
+	protocol=smart
+else
+	protocol=dumb
+fi
+
+test_description="test http-push ($protocol)
+
+This test runs various sanity checks on http-push."
+
+. ./test-lib.sh
+
+ROOT_PATH="$PWD"
+if test -z "$LIB_HTTPD_GIT"
+then
+	LIB_HTTPD_DAV=t
+fi
+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
+
+if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
+then
+	say "skipping test, USE_CURL_MULTI is not defined"
+	test_done
+fi
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success 'setup remote repository' '
+	cd "$ROOT_PATH" &&
+	mkdir test_repo &&
+	cd test_repo &&
+	git init &&
+	: >path1 &&
+	git add path1 &&
+	test_tick &&
+	git commit -m initial &&
+	cd - &&
+	git clone --bare test_repo test_repo.git &&
+	cd test_repo.git &&
+	ORIG_HEAD=$(git rev-parse --verify HEAD) &&
+	if test -n "$LIB_HTTPD_GIT"
+	then
+		git config http.receivepack true
+	else
+		git --bare update-server-info &&
+		mv hooks/post-update.sample hooks/post-update
+	fi &&
+	cd - &&
+	mv test_repo.git "$HTTPD_GIT_PATH"
+'
+
+test_expect_success 'clone remote repository' '
+	cd "$ROOT_PATH" &&
+	git clone $HTTPD_GIT_URL/test_repo.git test_repo_clone
+'
+
+test_expect_success 'push to remote repository with packed refs' '
+	cd "$ROOT_PATH"/test_repo_clone &&
+	: >path2 &&
+	git add path2 &&
+	test_tick &&
+	git commit -m path2 &&
+	HEAD=$(git rev-parse --verify HEAD) &&
+	git push &&
+	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
+	 test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'push already up-to-date' '
+	git push
+'
+
+test_expect_success 'push to remote repository with unpacked refs' '
+	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
+	 rm packed-refs &&
+	 git update-ref refs/heads/master $ORIG_HEAD &&
+	 git --bare update-server-info) &&
+	git push &&
+	(cd "$HTTPD_GIT_PATH"/test_repo.git &&
+	 test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'http-push fetches unpacked objects' '
+	cp -R "$HTTPD_GIT_PATH"/test_repo.git \
+		"$HTTPD_GIT_PATH"/test_repo_unpacked.git &&
+
+	git clone $HTTPD_GIT_URL/test_repo_unpacked.git \
+		"$ROOT_PATH"/fetch_unpacked &&
+
+	# By reset, we force git to retrieve the object
+	(cd "$ROOT_PATH"/fetch_unpacked &&
+	 git reset --hard HEAD^ &&
+	 git remote rm origin &&
+	 git reflog expire --expire=0 --all &&
+	 git prune &&
+	 git push -f -v $HTTPD_GIT_URL/test_repo_unpacked.git master)
+'
+
+test_expect_success 'http-push fetches packed objects' '
+	cp -R "$HTTPD_GIT_PATH"/test_repo.git \
+		"$HTTPD_GIT_PATH"/test_repo_packed.git &&
+
+	git clone $HTTPD_GIT_URL/test_repo_packed.git \
+		"$ROOT_PATH"/test_repo_clone_packed &&
+
+	(cd "$HTTPD_GIT_PATH"/test_repo_packed.git &&
+	 git --bare repack &&
+	 git --bare prune-packed) &&
+
+	# By reset, we force git to retrieve the packed object
+	(cd "$ROOT_PATH"/test_repo_clone_packed &&
+	 git reset --hard HEAD^ &&
+	 git remote rm origin &&
+	 git reflog expire --expire=0 --all &&
+	 git prune &&
+	 git push -f -v $HTTPD_GIT_URL/test_repo_packed.git master)
+'
+
+test_expect_success 'create and delete remote branch' '
+	cd "$ROOT_PATH"/test_repo_clone &&
+	git checkout -b dev &&
+	: >path3 &&
+	git add path3 &&
+	test_tick &&
+	git commit -m dev &&
+	git push origin dev &&
+	git fetch &&
+	git push origin :dev &&
+	git fetch &&
+	test_must_fail git show-ref --verify refs/remotes/origin/dev
+'
+
+test -n "$LIB_HTTPD_GIT" ||
+test_expect_success 'MKCOL sends directory names with trailing slashes' '
+
+	! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
+
+'
+
+x1="[0-9a-f]"
+x2="$x1$x1"
+x5="$x1$x1$x1$x1$x1"
+x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
+x40="$x38$x2"
+
+test -n "$LIB_HTTPD_GIT" ||
+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
+	sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
+	grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
+
+'
+
+stop_httpd
+
+test_done
-- 
1.6.5.1.208.gd7b37

  reply	other threads:[~2009-10-28 17:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-25 12:06 Smart HTTP tests Clemens Buchacher
2009-10-25 12:06 ` [PATCH 1/3] update http tests according to remote-curl capabilities Clemens Buchacher
2009-10-25 12:06   ` [PATCH 2/3] remote-helpers: return successfully if everything up-to-date Clemens Buchacher
2009-10-25 12:06     ` [PATCH 3/3] add smart HTTP tests Clemens Buchacher
2009-10-28  0:17       ` Shawn O. Pearce
2009-10-28 17:52         ` Clemens Buchacher [this message]
2009-10-28  0:11     ` [PATCH 2/3] remote-helpers: return successfully if everything up-to-date Shawn O. Pearce
2009-10-28  7:18       ` Junio C Hamano
2009-10-28  0:10   ` [PATCH 1/3] update http tests according to remote-curl capabilities Shawn O. Pearce

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=20091028175226.GA10264@localhost \
    --to=drizzd@aon.at \
    --cc=git@vger.kernel.org \
    --cc=lodatom@gmail.com \
    --cc=spearce@spearce.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.