Skip to content

Commit 77fb36a

Browse files
peffgitster
authored andcommitted
t5541: run "used receive-pack service" test earlier
There's a test in t5541 that confirms that "git push" makes two requests (a GET to /info/refs, and a POST to /git-receive-pack). However, it's a noop unless GIT_TEST_PROTOCOL_VERSION is set to "0", due to 8a1b097 (test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate, 2019-12-23). This means that almost nobody runs it. And indeed, it has been broken since b0c4adc (remote-curl: send Accept-Language header to server, 2022-07-11). But the fault is not in that commit, but in how brittle the test is. It runs after several operations have been performed, which means that it expects to see the complete set of requests made so far in the script. Commit b0c4adc added a new test, which means that the "used receive-pack service" test must be updated, too. Let's fix this by making the test less brittle. We'll move it higher in the script, right after the first push has completed. And we'll clear the access log right before doing the push, so we'll see only the requests from that command. This is technically testing less, in that we won't check that all of those other requests also correctly used smart http. But there's no particular reason think that if the first one did, the others wouldn't. After this patch, running: GIT_TEST_PROTOCOL_VERSION=0 ./t5541-http-push-smart.sh passes, whereas it did not before. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 768bb23 commit 77fb36a

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

t/t5541-http-push-smart.sh

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
4141
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
4242
EOF
4343
test_expect_success 'no empty path components' '
44-
# Clear the log, so that it does not affect the "used receive-pack
45-
# service" test which reads the log too.
46-
test_when_finished ">\"\$HTTPD_ROOT_PATH\"/access.log" &&
47-
4844
# In the URL, add a trailing slash, and see if git appends yet another
4945
# slash.
5046
cd "$ROOT_PATH" &&
@@ -67,6 +63,10 @@ test_expect_success 'clone remote repository' '
6763
'
6864

6965
test_expect_success 'push to remote repository (standard)' '
66+
# Clear the log, so that the "used receive-pack service" test below
67+
# sees just what we did here.
68+
>"$HTTPD_ROOT_PATH"/access.log &&
69+
7070
cd "$ROOT_PATH"/test_repo_clone &&
7171
: >path2 &&
7272
git add path2 &&
@@ -80,6 +80,20 @@ test_expect_success 'push to remote repository (standard)' '
8080
test $HEAD = $(git rev-parse --verify HEAD))
8181
'
8282

83+
test_expect_success 'used receive-pack service' '
84+
cat >exp <<-\EOF &&
85+
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
86+
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
87+
EOF
88+
89+
# NEEDSWORK: If the overspecification of the expected result is reduced, we
90+
# might be able to run this test in all protocol versions.
91+
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
92+
then
93+
check_access_log exp
94+
fi
95+
'
96+
8397
test_expect_success 'push to remote repository (standard) with sending Accept-Language' '
8498
cat >exp <<-\EOF &&
8599
=> Send header: Accept-Language: ko-KR, *;q=0.9
@@ -141,28 +155,6 @@ test_expect_success 'rejected update prints status' '
141155
'
142156
rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
143157

144-
cat >exp <<EOF
145-
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
146-
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
147-
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
148-
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
149-
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
150-
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
151-
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
152-
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
153-
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
154-
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
155-
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
156-
EOF
157-
test_expect_success 'used receive-pack service' '
158-
# NEEDSWORK: If the overspecification of the expected result is reduced, we
159-
# might be able to run this test in all protocol versions.
160-
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
161-
then
162-
check_access_log exp
163-
fi
164-
'
165-
166158
test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
167159
"$ROOT_PATH"/test_repo_clone main success
168160

0 commit comments

Comments
 (0)