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

[PATCH v3 13/13] http tests: use "test_hook" for "smart" and "dumb" http tests

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Mar 17, 2022, 10:13 UTC
Message-ID
<patch-v3-13.13-2dffde32036-20220317T100820Z-avarab@gmail.com>
In-Reply-To
<cover-v3-00.13-00000000000-20220317T100820Z-avarab@gmail.com>

Change the http tests to use "test_hook" insteadd of "write_script". In both cases we can get rid of sub-shelling. For "t/t5550-http-fetch-dumb.sh" add a trivial helper which sets up the hook and calls "update-server-info".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5541-http-push-smart.sh | 10 ++++------
 t/t5550-http-fetch-dumb.sh | 25 ++++++++++---------------
 2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index ab4b5cfcd11..2f09ff4fac6 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -419,10 +419,7 @@ test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' '
 '
 
 test_expect_success GPG 'push with post-receive to inspect certificate' '
-	(
-		cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-		mkdir -p hooks &&
-		write_script hooks/post-receive <<-\EOF &&
+	test_hook -C "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git post-receive <<-\EOF &&
 		# discard the update list
 		cat >/dev/null
 		# record the push certificate
@@ -437,8 +434,9 @@ test_expect_success GPG 'push with post-receive to inspect certificate' '
 		NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
 		NONCE=${GIT_PUSH_CERT_NONCE-nononce}
 		E_O_F
-		EOF
-
+	EOF
+	(
+		cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
 		git config receive.certnonceseed sekrit &&
 		git config receive.certnonceslop 30
 	) &&
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 259203926a9..f0d9cd584d3 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -25,16 +25,17 @@ test_expect_success 'setup repository' '
 	git commit -m two
 '
 
+setup_post_update_server_info_hook () {
+	test_hook --setup -C "$1" post-update <<-\EOF &&
+	exec git update-server-info
+	EOF
+	git -C "$1" update-server-info
+}
+
 test_expect_success 'create http-accessible bare repository with loose objects' '
 	cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-	(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-	 git config core.bare true &&
-	 mkdir -p hooks &&
-	 write_script "hooks/post-update" <<-\EOF &&
-	 exec git update-server-info
-	EOF
-	 hooks/post-update
-	) &&
+	git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config core.bare true &&
+	setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 	git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
 	git push public main:main
 '
@@ -62,13 +63,7 @@ test_expect_success 'create password-protected repository' '
 
 test_expect_success 'create empty remote repository' '
 	git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
-	(cd "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
-	 mkdir -p hooks &&
-	 write_script "hooks/post-update" <<-\EOF &&
-	 exec git update-server-info
-	EOF
-	 hooks/post-update
-	)
+	setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/empty.git"
 '
 
 test_expect_success 'empty dumb HTTP repository has default hash algorithm' '
-- 
2.35.1.1384.g7d2906948a1
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 47 of 51 in “tests: add and use a "test_hook" wrapper + hook fixes”
  1. 00/10 tests: add and use a "test_hook" wrapper + hook fixesÆvar Arnfjörð Bjarmason, Mar 2, 2022
  2. 02/10 t5540: don't rely on "hook/post-update.sample"Ævar Arnfjörð Bjarmason, Mar 2, 2022
  3. Junio C HamanoMar 2, 2022
  4. 01/10 hook tests: turn exit code assertions into a loopÆvar Arnfjörð Bjarmason, Mar 2, 2022
  5. Junio C HamanoMar 2, 2022
  6. 03/10 tests: assume the hooks are disabled by defaultÆvar Arnfjörð Bjarmason, Mar 2, 2022
  7. Junio C HamanoMar 2, 2022
  8. 04/10 bugreport tests: tighten up "git bugreport -s hooks" testÆvar Arnfjörð Bjarmason, Mar 2, 2022
  9. Junio C HamanoMar 2, 2022
  10. 05/10 tests: indent and add hook setup to "test_expect_success"Ævar Arnfjörð Bjarmason, Mar 2, 2022
  11. Junio C HamanoMar 2, 2022
  12. 06/10 hook tests: get rid of unnecessary sub-shellsÆvar Arnfjörð Bjarmason, Mar 2, 2022
  13. Junio C HamanoMar 2, 2022
  14. 07/10 fetch+push tests: have tests clean up their own messÆvar Arnfjörð Bjarmason, Mar 2, 2022
  15. Junio C HamanoMar 2, 2022
  16. 10/10 tests: change "cat && chmod +x" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 2, 2022
  17. Eric SunshineMar 3, 2022
  18. 08/10 test-lib-functions: add and use a "test_hook" wrapperÆvar Arnfjörð Bjarmason, Mar 2, 2022
  19. Junio C HamanoMar 2, 2022
  20. 09/10 tests: change "mkdir -p && write_script" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 2, 2022
  21. Junio C HamanoMar 2, 2022
  22. Junio C HamanoMar 2, 2022
  23. 00/10 tests: add and use a "test_hook" wrapper + hook fixesÆvar Arnfjörð Bjarmason, Mar 7, 2022
  24. 01/10 hook tests: turn exit code assertions into a loopÆvar Arnfjörð Bjarmason, Mar 7, 2022
  25. 02/10 t5540: don't rely on "hook/post-update.sample"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  26. 03/10 tests: assume the hooks are disabled by defaultÆvar Arnfjörð Bjarmason, Mar 7, 2022
  27. 04/10 bugreport tests: tighten up "git bugreport -s hooks" testÆvar Arnfjörð Bjarmason, Mar 7, 2022
  28. 05/10 tests: indent and add hook setup to "test_expect_success"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  29. 06/10 hook tests: get rid of unnecessary sub-shellsÆvar Arnfjörð Bjarmason, Mar 7, 2022
  30. 08/10 test-lib-functions: add and use a "test_hook" wrapperÆvar Arnfjörð Bjarmason, Mar 7, 2022
  31. 07/10 fetch+push tests: have tests clean up their own messÆvar Arnfjörð Bjarmason, Mar 7, 2022
  32. 10/10 tests: change "cat && chmod +x" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  33. 09/10 tests: change "mkdir -p && write_script" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 7, 2022
  34. Junio C HamanoMar 7, 2022
  35. 00/13 tests: add and use a "test_hook" wrapper + hook fixesÆvar Arnfjörð Bjarmason, Mar 17, 2022
  36. 01/13 test-lib-functions: add and use a "test_hook" wrapperÆvar Arnfjörð Bjarmason, Mar 17, 2022
  37. 03/13 http tests: don't rely on "hook/post-update.sample"Ævar Arnfjörð Bjarmason, Mar 17, 2022
  38. 02/13 hook tests: turn exit code assertions into a loopÆvar Arnfjörð Bjarmason, Mar 17, 2022
  39. 04/13 tests: assume the hooks are disabled by defaultÆvar Arnfjörð Bjarmason, Mar 17, 2022
  40. 05/13 bugreport tests: tighten up "git bugreport -s hooks" testÆvar Arnfjörð Bjarmason, Mar 17, 2022
  41. 06/13 fetch+push tests: use "test_hook" and "test_when_finished" patternÆvar Arnfjörð Bjarmason, Mar 17, 2022
  42. 08/13 tests: change "cat && chmod +x" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 17, 2022
  43. 10/13 tests: use "test_hook" for misc "mkdir -p" and "chmod" casesÆvar Arnfjörð Bjarmason, Mar 17, 2022
  44. 07/13 gc + p4 tests: use "test_hook", remove sub-shellsÆvar Arnfjörð Bjarmason, Mar 17, 2022
  45. 09/13 tests: change "mkdir -p && write_script" to use "test_hook"Ævar Arnfjörð Bjarmason, Mar 17, 2022
  46. 11/13 tests: extend "test_hook" for "rm" and "chmod -x", convert "$HOOK"Ævar Arnfjörð Bjarmason, Mar 17, 2022
  47. 13/13 http tests: use "test_hook" for "smart" and "dumb" http testsÆvar Arnfjörð Bjarmason, Mar 17, 2022
  48. 12/13 proc-receive hook tests: use "test_hook" instead of "write_script"Ævar Arnfjörð Bjarmason, Mar 17, 2022
  49. Junio C HamanoMar 17, 2022
  50. Ævar Arnfjörð BjarmasonMar 17, 2022
  51. Junio C HamanoMar 17, 2022

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.