diff mbox series

[02/10] t5540: don't rely on "hook/post-update.sample"

Message ID patch-02.10-4bee939a894-20220302T131859Z-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series tests: add and use a "test_hook" wrapper + hook fixes | expand

Commit Message

Ævar Arnfjörð Bjarmason March 2, 2022, 1:22 p.m. UTC
Change code added in a87679339c0 (test: rename http fetch and push
test files, 2014-02-06) to stop relying on the "exec git
update-server-info" in "templates/hooks--post-update.sample", let's
instead inline the expected hook in the test itself.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t5540-http-push-webdav.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Junio C Hamano March 2, 2022, 9:06 p.m. UTC | #1
Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Change code added in a87679339c0 (test: rename http fetch and push
> test files, 2014-02-06) to stop relying on the "exec git
> update-server-info" in "templates/hooks--post-update.sample", let's
> instead inline the expected hook in the test itself.

For this particular hook, it indeed is a good change, as future
post-update samples we ship may have something quite different.

I do not know if it is a good idea in general, though.  We want
to promise shipping certain sample scripts as part of the default
install, and the default install is what our tests check.  We want
to keep something that ensures the default install does ship the
sample we want to include, and such tests do need to rely on the
presence of .sample files.  But this script does not need to be
the one to do so.

>  	git --bare update-server-info &&
> -	mv hooks/post-update.sample hooks/post-update &&
> +	write_script hooks/post-update <<-\EOF &&
> +	exec git update-server-info
> +	EOF
>  	ORIG_HEAD=$(git rev-parse --verify HEAD) &&
>  	cd - &&
>  	mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"

OK.

We might want to deprecate and remove the support for dumb walkers,
but until then, this looks superb.

Thanks.
diff mbox series

Patch

diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh
index b0dbacf0b9b..380e97c1762 100755
--- a/t/t5540-http-push-webdav.sh
+++ b/t/t5540-http-push-webdav.sh
@@ -42,7 +42,9 @@  test_expect_success 'setup remote repository' '
 	git clone --bare test_repo test_repo.git &&
 	cd test_repo.git &&
 	git --bare update-server-info &&
-	mv hooks/post-update.sample hooks/post-update &&
+	write_script hooks/post-update <<-\EOF &&
+	exec git update-server-info
+	EOF
 	ORIG_HEAD=$(git rev-parse --verify HEAD) &&
 	cd - &&
 	mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"