t5552: suppress upload-pack trace output

The t5552 test script uses GIT_TRACE_PACKET to monitor what git-fetch sends and receives. However, because we're accessing a local repository, the child upload-pack also sends trace output to the same file. On Linux, this works out OK. We open the trace file with O_APPEND, so all writes are atomically positioned at the end of the file. No data can be overwritten or omitted. And since we prepare our small writes in a strbuf and write them with a single write(), we should see each line as an atomic unit. The order of lines between the two processes is undefined, but the test script greps only for "fetch>" or "fetch<" lines. So under Linux, the test results are deterministic. The test fails intermittently on Windows, however, reportedly even overwriting bits of the output file (i.e., O_APPEND does not seem to give us an atomic position+write). Since the test only cares about the trace output from fetch, we can just disable the output from upload-pack. That doesn't solve the greater question of O_APPEND/trace issues under Windows, but it easily fixes the flakiness from this test. Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 10, 2018 at 10:09 UTC b6e7fc4fc892dfaeb716101fa77653183a374c78
1 file changed +18 -5
t/t5552-skipping-fetch-negotiator.sh
+18 -5
@@ -28,6 +28,19 @@ have_not_sent () {
28 done
29 }
30
31 +# trace_fetch <client_dir> <server_dir> [args]
32 +#
33 +# Trace the packet output of fetch, but make sure we disable the variable
34 +# in the child upload-pack, so we don't combine the results in the same file.
35 +trace_fetch () {
36 + client=$1; shift
37 + server=$1; shift
38 + GIT_TRACE_PACKET="$(pwd)/trace" \
39 + git -C "$client" fetch \
40 + --upload-pack 'unset GIT_TRACE_PACKET; git-upload-pack' \
41 + "$server" "$@"
42 +}
43 +
44 test_expect_success 'commits with no parents are sent regardless of skip distance' '
45 git init server &&
46 test_commit -C server to_fetch &&
@@ -42,7 +55,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
55 # "c1" has no parent, it is still sent as "have" even though it would
56 # normally be skipped.
57 test_config -C client fetch.negotiationalgorithm skipping &&
45 - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" &&
58 + trace_fetch client "$(pwd)/server" &&
59 have_sent c7 c5 c2 c1 &&
60 have_not_sent c6 c4 c3
61 '
@@ -65,7 +78,7 @@ test_expect_success 'when two skips collide, favor the larger one' '
78 # the next "have" sent will be "c1" (from "c6" skip 4) and not "c4"
79 # (from "c5side" skip 1).
80 test_config -C client fetch.negotiationalgorithm skipping &&
68 - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" &&
81 + trace_fetch client "$(pwd)/server" &&
82 have_sent c5side c11 c9 c6 c1 &&
83 have_not_sent c10 c8 c7 c5 c4 c3 c2
84 '
@@ -91,7 +104,7 @@ test_expect_success 'use ref advertisement to filter out commits' '
104 # not need to send any ancestors of "c3", but we still need to send "c3"
105 # itself.
106 test_config -C client fetch.negotiationalgorithm skipping &&
94 - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch origin to_fetch &&
107 + trace_fetch client origin to_fetch &&
108 have_sent c5 c4^ c2side &&
109 have_not_sent c4 c4^^ c4^^^
110 '
@@ -121,7 +134,7 @@ test_expect_success 'handle clock skew' '
134 # and sent, because (due to clock skew) its only parent has already been
135 # popped off the priority queue.
136 test_config -C client fetch.negotiationalgorithm skipping &&
124 - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" &&
137 + trace_fetch client "$(pwd)/server" &&
138 have_sent c2 c1 old4 old2 old1 &&
139 have_not_sent old3
140 '
@@ -153,7 +166,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
166 test_commit -C server commit-on-b1 &&
167
168 test_config -C client fetch.negotiationalgorithm skipping &&
156 - GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch "$(pwd)/server" to_fetch &&
169 + trace_fetch client "$(pwd)/server" to_fetch &&
170 grep " fetch" trace &&
171
172 # fetch-pack sends 2 requests each containing 16 "have" lines before