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

[PATCH] t5540: test both smart and dumb protocols

From
Clemens Buchacher <drizzd@aon.at>
Date
Oct 28, 2009, 17:52 UTC
Message-ID
<20091028175226.GA10264@localhost>
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:
Show 6 quoted lines
> 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
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 6 of 9 in “Smart HTTP tests”
  1. Clemens BuchacherOct 25, 2009
  2. 1/3 update http tests according to remote-curl capabilitiesClemens Buchacher, Oct 25, 2009
  3. 2/3 remote-helpers: return successfully if everything up-to-dateClemens Buchacher, Oct 25, 2009
  4. 3/3 add smart HTTP testsClemens Buchacher, Oct 25, 2009
  5. Shawn O. PearceOct 28, 2009
  6. t5540: test both smart and dumb protocolsClemens Buchacher, Oct 28, 2009
  7. Shawn O. PearceOct 28, 2009
  8. Junio C HamanoOct 28, 2009
  9. Shawn O. PearceOct 28, 2009

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.