Skip to content

Commit 77067b6

Browse files
committed
Merge branch 'sg/do-not-skip-non-httpd-tests'
Test fix. * sg/do-not-skip-non-httpd-tests: t: warn against adding non-httpd-specific tests after sourcing 'lib-httpd' t5703: run all non-httpd-specific tests before sourcing 'lib-httpd.sh' t5510-fetch: run non-httpd-specific test before sourcing 'lib-httpd.sh'
2 parents 1b01cdb + decfe05 commit 77067b6

10 files changed

+153
-122
lines changed

t/t0410-partial-clone.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,7 @@ test_expect_success 'fetching of missing objects from an HTTP server' '
518518
git verify-pack --verbose "$IDX" | grep "$HASH"
519519
'
520520

521+
# DO NOT add non-httpd-specific tests here, because the last part of this
522+
# test script is only executed when httpd is available and enabled.
523+
521524
test_done

t/t5500-fetch-pack.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,4 +920,7 @@ test_expect_success 'fetch with --filter=blob:limit=0 and HTTP' '
920920
fetch_filter_blob_limit_zero "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
921921
'
922922

923+
# DO NOT add non-httpd-specific tests here, because the last part of this
924+
# test script is only executed when httpd is available and enabled.
925+
923926
test_done

t/t5510-fetch.sh

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,29 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' '
902902
test_cmp expect actual
903903
'
904904

905+
test_expect_success '--no-show-forced-updates' '
906+
mkdir forced-updates &&
907+
(
908+
cd forced-updates &&
909+
git init &&
910+
test_commit 1 &&
911+
test_commit 2
912+
) &&
913+
git clone forced-updates forced-update-clone &&
914+
git clone forced-updates no-forced-update-clone &&
915+
git -C forced-updates reset --hard HEAD~1 &&
916+
(
917+
cd forced-update-clone &&
918+
git fetch --show-forced-updates origin 2>output &&
919+
test_i18ngrep "(forced update)" output
920+
) &&
921+
(
922+
cd no-forced-update-clone &&
923+
git fetch --no-show-forced-updates origin 2>output &&
924+
test_i18ngrep ! "(forced update)" output
925+
)
926+
'
927+
905928
setup_negotiation_tip () {
906929
SERVER="$1"
907930
URL="$2"
@@ -978,27 +1001,7 @@ test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protoc
9781001
check_negotiation_tip
9791002
'
9801003

981-
test_expect_success '--no-show-forced-updates' '
982-
mkdir forced-updates &&
983-
(
984-
cd forced-updates &&
985-
git init &&
986-
test_commit 1 &&
987-
test_commit 2
988-
) &&
989-
git clone forced-updates forced-update-clone &&
990-
git clone forced-updates no-forced-update-clone &&
991-
git -C forced-updates reset --hard HEAD~1 &&
992-
(
993-
cd forced-update-clone &&
994-
git fetch --show-forced-updates origin 2>output &&
995-
test_i18ngrep "(forced update)" output
996-
) &&
997-
(
998-
cd no-forced-update-clone &&
999-
git fetch --no-show-forced-updates origin 2>output &&
1000-
test_i18ngrep ! "(forced update)" output
1001-
)
1002-
'
1004+
# DO NOT add non-httpd-specific tests here, because the last part of this
1005+
# test script is only executed when httpd is available and enabled.
10031006

10041007
test_done

t/t5537-fetch-shallow.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,4 +255,7 @@ test_expect_success 'shallow fetches check connectivity before writing shallow f
255255
git -C client fsck
256256
'
257257

258+
# DO NOT add non-httpd-specific tests here, because the last part of this
259+
# test script is only executed when httpd is available and enabled.
260+
258261
test_done

t/t5545-push-options.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,7 @@ test_expect_success 'push options keep quoted characters intact (http)' '
278278
test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH"/upstream.git/hooks/pre-receive.push_options
279279
'
280280

281+
# DO NOT add non-httpd-specific tests here, because the last part of this
282+
# test script is only executed when httpd is available and enabled.
283+
281284
test_done

t/t5601-clone.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,4 +739,7 @@ test_expect_success 'partial clone using HTTP' '
739739
partial_clone "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
740740
'
741741

742+
# DO NOT add non-httpd-specific tests here, because the last part of this
743+
# test script is only executed when httpd is available and enabled.
744+
742745
test_done

t/t5616-partial-clone.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,7 @@ test_expect_success 'tolerate server sending REF_DELTA against missing promisor
417417
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
418418
'
419419

420+
# DO NOT add non-httpd-specific tests here, because the last part of this
421+
# test script is only executed when httpd is available and enabled.
422+
420423
test_done

t/t5700-protocol-v1.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,7 @@ test_expect_success 'push with http:// using protocol v1' '
292292
grep "git< version 1" log
293293
'
294294

295+
# DO NOT add non-httpd-specific tests here, because the last part of this
296+
# test script is only executed when httpd is available and enabled.
297+
295298
test_done

t/t5702-protocol-v2.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,4 +723,7 @@ test_expect_success 'when server does not send "ready", expect FLUSH' '
723723
test_i18ngrep "expected no other sections to be sent after no .ready." err
724724
'
725725

726+
# DO NOT add non-httpd-specific tests here, because the last part of this
727+
# test script is only executed when httpd is available and enabled.
728+
726729
test_done

t/t5703-upload-pack-ref-in-want.sh

Lines changed: 104 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -157,106 +157,6 @@ test_expect_success 'want-ref with ref we already have commit for' '
157157
check_output
158158
'
159159

160-
. "$TEST_DIRECTORY"/lib-httpd.sh
161-
start_httpd
162-
163-
REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
164-
LOCAL_PRISTINE="$(pwd)/local_pristine"
165-
166-
test_expect_success 'setup repos for change-while-negotiating test' '
167-
(
168-
git init "$REPO" &&
169-
cd "$REPO" &&
170-
>.git/git-daemon-export-ok &&
171-
test_commit m1 &&
172-
git tag -d m1 &&
173-
174-
# Local repo with many commits (so that negotiation will take
175-
# more than 1 request/response pair)
176-
git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
177-
cd "$LOCAL_PRISTINE" &&
178-
git checkout -b side &&
179-
test_commit_bulk --id=s 33 &&
180-
181-
# Add novel commits to upstream
182-
git checkout master &&
183-
cd "$REPO" &&
184-
test_commit m2 &&
185-
test_commit m3 &&
186-
git tag -d m2 m3
187-
) &&
188-
git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_sed/repo" &&
189-
git -C "$LOCAL_PRISTINE" config protocol.version 2
190-
'
191-
192-
inconsistency () {
193-
# Simulate that the server initially reports $2 as the ref
194-
# corresponding to $1, and after that, $1 as the ref corresponding to
195-
# $1. This corresponds to the real-life situation where the server's
196-
# repository appears to change during negotiation, for example, when
197-
# different servers in a load-balancing arrangement serve (stateless)
198-
# RPCs during a single negotiation.
199-
printf "s/%s/%s/" \
200-
$(git -C "$REPO" rev-parse $1 | tr -d "\n") \
201-
$(git -C "$REPO" rev-parse $2 | tr -d "\n") \
202-
>"$HTTPD_ROOT_PATH/one-time-sed"
203-
}
204-
205-
test_expect_success 'server is initially ahead - no ref in want' '
206-
git -C "$REPO" config uploadpack.allowRefInWant false &&
207-
rm -rf local &&
208-
cp -r "$LOCAL_PRISTINE" local &&
209-
inconsistency master 1234567890123456789012345678901234567890 &&
210-
test_must_fail git -C local fetch 2>err &&
211-
test_i18ngrep "fatal: remote error: upload-pack: not our ref" err
212-
'
213-
214-
test_expect_success 'server is initially ahead - ref in want' '
215-
git -C "$REPO" config uploadpack.allowRefInWant true &&
216-
rm -rf local &&
217-
cp -r "$LOCAL_PRISTINE" local &&
218-
inconsistency master 1234567890123456789012345678901234567890 &&
219-
git -C local fetch &&
220-
221-
git -C "$REPO" rev-parse --verify master >expected &&
222-
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
223-
test_cmp expected actual
224-
'
225-
226-
test_expect_success 'server is initially behind - no ref in want' '
227-
git -C "$REPO" config uploadpack.allowRefInWant false &&
228-
rm -rf local &&
229-
cp -r "$LOCAL_PRISTINE" local &&
230-
inconsistency master "master^" &&
231-
git -C local fetch &&
232-
233-
git -C "$REPO" rev-parse --verify "master^" >expected &&
234-
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
235-
test_cmp expected actual
236-
'
237-
238-
test_expect_success 'server is initially behind - ref in want' '
239-
git -C "$REPO" config uploadpack.allowRefInWant true &&
240-
rm -rf local &&
241-
cp -r "$LOCAL_PRISTINE" local &&
242-
inconsistency master "master^" &&
243-
git -C local fetch &&
244-
245-
git -C "$REPO" rev-parse --verify "master" >expected &&
246-
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
247-
test_cmp expected actual
248-
'
249-
250-
test_expect_success 'server loses a ref - ref in want' '
251-
git -C "$REPO" config uploadpack.allowRefInWant true &&
252-
rm -rf local &&
253-
cp -r "$LOCAL_PRISTINE" local &&
254-
echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-sed" &&
255-
test_must_fail git -C local fetch 2>err &&
256-
257-
test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err
258-
'
259-
260160
REPO="$(pwd)/repo"
261161
LOCAL_PRISTINE="$(pwd)/local_pristine"
262162

@@ -372,4 +272,108 @@ test_expect_success 'fetching with wildcard that matches multiple refs' '
372272
grep "want-ref refs/heads/o/bar" log
373273
'
374274

275+
. "$TEST_DIRECTORY"/lib-httpd.sh
276+
start_httpd
277+
278+
REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
279+
LOCAL_PRISTINE="$(pwd)/local_pristine"
280+
281+
test_expect_success 'setup repos for change-while-negotiating test' '
282+
(
283+
git init "$REPO" &&
284+
cd "$REPO" &&
285+
>.git/git-daemon-export-ok &&
286+
test_commit m1 &&
287+
git tag -d m1 &&
288+
289+
# Local repo with many commits (so that negotiation will take
290+
# more than 1 request/response pair)
291+
rm -rf "$LOCAL_PRISTINE" &&
292+
git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
293+
cd "$LOCAL_PRISTINE" &&
294+
git checkout -b side &&
295+
test_commit_bulk --id=s 33 &&
296+
297+
# Add novel commits to upstream
298+
git checkout master &&
299+
cd "$REPO" &&
300+
test_commit m2 &&
301+
test_commit m3 &&
302+
git tag -d m2 m3
303+
) &&
304+
git -C "$LOCAL_PRISTINE" remote set-url origin "http://127.0.0.1:$LIB_HTTPD_PORT/one_time_sed/repo" &&
305+
git -C "$LOCAL_PRISTINE" config protocol.version 2
306+
'
307+
308+
inconsistency () {
309+
# Simulate that the server initially reports $2 as the ref
310+
# corresponding to $1, and after that, $1 as the ref corresponding to
311+
# $1. This corresponds to the real-life situation where the server's
312+
# repository appears to change during negotiation, for example, when
313+
# different servers in a load-balancing arrangement serve (stateless)
314+
# RPCs during a single negotiation.
315+
printf "s/%s/%s/" \
316+
$(git -C "$REPO" rev-parse $1 | tr -d "\n") \
317+
$(git -C "$REPO" rev-parse $2 | tr -d "\n") \
318+
>"$HTTPD_ROOT_PATH/one-time-sed"
319+
}
320+
321+
test_expect_success 'server is initially ahead - no ref in want' '
322+
git -C "$REPO" config uploadpack.allowRefInWant false &&
323+
rm -rf local &&
324+
cp -r "$LOCAL_PRISTINE" local &&
325+
inconsistency master 1234567890123456789012345678901234567890 &&
326+
test_must_fail git -C local fetch 2>err &&
327+
test_i18ngrep "fatal: remote error: upload-pack: not our ref" err
328+
'
329+
330+
test_expect_success 'server is initially ahead - ref in want' '
331+
git -C "$REPO" config uploadpack.allowRefInWant true &&
332+
rm -rf local &&
333+
cp -r "$LOCAL_PRISTINE" local &&
334+
inconsistency master 1234567890123456789012345678901234567890 &&
335+
git -C local fetch &&
336+
337+
git -C "$REPO" rev-parse --verify master >expected &&
338+
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
339+
test_cmp expected actual
340+
'
341+
342+
test_expect_success 'server is initially behind - no ref in want' '
343+
git -C "$REPO" config uploadpack.allowRefInWant false &&
344+
rm -rf local &&
345+
cp -r "$LOCAL_PRISTINE" local &&
346+
inconsistency master "master^" &&
347+
git -C local fetch &&
348+
349+
git -C "$REPO" rev-parse --verify "master^" >expected &&
350+
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
351+
test_cmp expected actual
352+
'
353+
354+
test_expect_success 'server is initially behind - ref in want' '
355+
git -C "$REPO" config uploadpack.allowRefInWant true &&
356+
rm -rf local &&
357+
cp -r "$LOCAL_PRISTINE" local &&
358+
inconsistency master "master^" &&
359+
git -C local fetch &&
360+
361+
git -C "$REPO" rev-parse --verify "master" >expected &&
362+
git -C local rev-parse --verify refs/remotes/origin/master >actual &&
363+
test_cmp expected actual
364+
'
365+
366+
test_expect_success 'server loses a ref - ref in want' '
367+
git -C "$REPO" config uploadpack.allowRefInWant true &&
368+
rm -rf local &&
369+
cp -r "$LOCAL_PRISTINE" local &&
370+
echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-sed" &&
371+
test_must_fail git -C local fetch 2>err &&
372+
373+
test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err
374+
'
375+
376+
# DO NOT add non-httpd-specific tests here, because the last part of this
377+
# test script is only executed when httpd is available and enabled.
378+
375379
test_done

0 commit comments

Comments
 (0)