Skip to content

Commit f6db603

Browse files
avargitster
authored andcommitted
http tests: use "test_hook" for "smart" and "dumb" http tests
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c39176b commit f6db603

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

t/t5541-http-push-smart.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,7 @@ test_expect_success CMDLINE_LIMIT 'push 2000 tags over http' '
419419
'
420420

421421
test_expect_success GPG 'push with post-receive to inspect certificate' '
422-
(
423-
cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
424-
mkdir -p hooks &&
425-
write_script hooks/post-receive <<-\EOF &&
422+
test_hook -C "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git post-receive <<-\EOF &&
426423
# discard the update list
427424
cat >/dev/null
428425
# record the push certificate
@@ -437,8 +434,9 @@ test_expect_success GPG 'push with post-receive to inspect certificate' '
437434
NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
438435
NONCE=${GIT_PUSH_CERT_NONCE-nononce}
439436
E_O_F
440-
EOF
441-
437+
EOF
438+
(
439+
cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
442440
git config receive.certnonceseed sekrit &&
443441
git config receive.certnonceslop 30
444442
) &&

t/t5550-http-fetch-dumb.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ test_expect_success 'setup repository' '
2525
git commit -m two
2626
'
2727

28+
setup_post_update_server_info_hook () {
29+
test_hook --setup -C "$1" post-update <<-\EOF &&
30+
exec git update-server-info
31+
EOF
32+
git -C "$1" update-server-info
33+
}
34+
2835
test_expect_success 'create http-accessible bare repository with loose objects' '
2936
cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
30-
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
31-
git config core.bare true &&
32-
mkdir -p hooks &&
33-
write_script "hooks/post-update" <<-\EOF &&
34-
exec git update-server-info
35-
EOF
36-
hooks/post-update
37-
) &&
37+
git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config core.bare true &&
38+
setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
3839
git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
3940
git push public main:main
4041
'
@@ -62,13 +63,7 @@ test_expect_success 'create password-protected repository' '
6263

6364
test_expect_success 'create empty remote repository' '
6465
git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
65-
(cd "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
66-
mkdir -p hooks &&
67-
write_script "hooks/post-update" <<-\EOF &&
68-
exec git update-server-info
69-
EOF
70-
hooks/post-update
71-
)
66+
setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/empty.git"
7267
'
7368

7469
test_expect_success 'empty dumb HTTP repository has default hash algorithm' '

0 commit comments

Comments
 (0)