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

[PATCH 2/4] t/lib-http.sh: add functions related to serve-git.py

From
Carlos Martín Nieto <cmn@dwim.me>
Date
Jun 12, 2024, 11:50 UTC
Message-ID
<20240612115028.1169183-3-cmn@dwim.me>
In-Reply-To
<20240612115028.1169183-1-cmn@dwim.me>
These functions manage the custom git serving script for use in tests.
Signed-off-by: Carlos Martín Nieto <cmn@dwim.me>
---
 t/lib-httpd.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index d83bafeab32..6454300a041 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -94,6 +94,8 @@ esac
 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
 test_set_port LIB_HTTPD_PORT
 
+test_set_port LIB_GIT_SERVE_PORT
+
 TEST_PATH="$TEST_DIRECTORY"/lib-httpd
 HTTPD_ROOT_PATH="$PWD"/httpd
 HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www
@@ -250,6 +252,24 @@ stop_httpd() {
 		-f "$TEST_PATH/apache.conf" $HTTPD_PARA -k stop
 }
 
+start_serve_git() {
+	test_atexit stop_serve_git
+
+	"$TEST_DIRECTORY"/lib-httpd/serve-git.py \
+		--document-root "$HTTPD_ROOT_PATH"/www \
+		--port "$LIB_GIT_SERVE_PORT" &
+
+	mkdir -p "$HTTPD_ROOT_PATH"
+	echo $! >"$HTTPD_ROOT_PATH"/git-serve.pid
+
+	GIT_SERVE_DEST=127.0.0.1:$LIB_GIT_SERVE_PORT
+	GIT_SERVE_URL=http://$GIT_SERVE_DEST
+}
+
+stop_serve_git() {
+	kill -9 $(cat "$HTTPD_ROOT_PATH"/git-serve.pid)
+}
+
 test_http_push_nonff () {
 	REMOTE_REPO=$1
 	LOCAL_REPO=$2
-- 
2.43.0
Previous: Jeff KingNext: Jeff King
Message 11 of 14 in “Report rejections over HTTP when the remote rejects during the transfer”
  1. 0/4 Report rejections over HTTP when the remote rejects during the transferCarlos Martín Nieto, Jun 12, 2024
  2. 1/4 t/lib-http: add serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  3. Junio C HamanoJun 12, 2024
  4. 4/4 remote-curl: read in the push report even if we fail to finish sending dataCarlos Martín Nieto, Jun 12, 2024
  5. Jeff KingJun 13, 2024
  6. Carlos Martín NietoJul 23, 2024
  7. 3/4 t5541: add test for rejecting a push due to packfile sizeCarlos Martín Nieto, Jun 12, 2024
  8. Taylor BlauJun 12, 2024
  9. Jeff KingJun 13, 2024
  10. Jeff KingJun 13, 2024
  11. 2/4 t/lib-http.sh: add functions related to serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  12. Jeff KingJun 13, 2024
  13. Jeff KingJun 13, 2024
  14. Carlos Martín NietoJul 23, 2024

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.