提交 2ad23273 编写于 作者: J Jeff King 提交者: Junio C Hamano

do not use GIT_TRACE_PACKET=3 in tests

Some test scripts use the GIT_TRACE mechanism to dump
debugging information to descriptor 3 (and point it to a
file using the shell). On Windows, however, bash is unable
to set up descriptor 3. We do not write our trace to the
file, and worse, we may interfere with other operations
happening on descriptor 3, causing tests to fail or even
behave inconsistently.

Prior to commit 97a83fa8 (upload-pack: remove packet debugging
harness), these tests used GIT_DEBUG_SEND_PACK, which only
supported output to a descriptor. The tests in t5503 were
always broken on Windows, and were marked to be skipped via
the NOT_MINGW prerequisite. In t5700, the tests used to pass
prior to 97a83fa8, but only because they were not careful
enough; because we only grepped the trace file, an empty
file looked successful to us. But post-97a83fa8, the writing
to descriptor 3 causes "git fetch" to hang (presumably
because we are throwing random bytes into the middle of the
protocol).

Now that we are using the GIT_TRACE mechanism, we can
improve both scripts by asking git to write directly to a
file rather than a descriptor. That fixes the hang in t5700,
and should allow t5503 to successfully run on Windows.

In both cases we now also use "test -s" to double-check that
our trace file actually contains output, which should reduce
the possibility of an erroneously passing test.
Signed-off-by: NJeff King <peff@peff.net>
Tested-by: NJohannes Sixt <j6t@kdbg.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 2a455202
......@@ -4,10 +4,6 @@ test_description='test automatic tag following'
. ./test-lib.sh
if ! test_have_prereq NOT_MINGW; then
say "GIT_TRACE_PACKET not supported - skipping tests"
fi
# End state of the repository:
#
# T - tag1 S - tag2
......@@ -17,7 +13,7 @@ fi
# \ C - origin/cat \
# origin/master master
test_expect_success NOT_MINGW setup '
test_expect_success setup '
test_tick &&
echo ichi >file &&
git add file &&
......@@ -39,33 +35,35 @@ test_expect_success NOT_MINGW setup '
'
U=UPLOAD_LOG
UPATH="$(pwd)/$U"
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
want $A
EOF
'
get_needs () {
test -s "$1" &&
perl -alne '
next unless $F[1] eq "upload-pack<";
last if $F[2] eq "0000";
print $F[2], " ", $F[3];
' "$@"
' "$1"
}
test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
test_expect_success 'fetch A (new commit : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_TRACE_PACKET=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $A = $(git rev-parse --verify origin/master)
) &&
get_needs $U >actual &&
test_cmp expect actual
'
test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
test_expect_success "create tag T on A, create C on branch cat" '
git tag -a -m tag1 tag1 $A &&
T=$(git rev-parse --verify tag1) &&
......@@ -77,18 +75,18 @@ test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
git checkout master
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
want $C
want $T
EOF
'
test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_TRACE_PACKET=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $C = $(git rev-parse --verify origin/cat) &&
test $T = $(git rev-parse --verify tag1) &&
test $A = $(git rev-parse --verify tag1^0)
......@@ -97,7 +95,7 @@ test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
test_cmp expect actual
'
test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
test_expect_success "create commits O, B, tag S on B" '
test_tick &&
echo O >file &&
git add file &&
......@@ -113,18 +111,18 @@ test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
S=$(git rev-parse --verify tag2)
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
want $B
want $S
EOF
'
test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
GIT_TRACE_PACKET=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $B = $(git rev-parse --verify origin/master) &&
test $B = $(git rev-parse --verify tag2^0) &&
test $S = $(git rev-parse --verify tag2)
......@@ -133,14 +131,14 @@ test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
test_cmp expect actual
'
test_expect_success NOT_MINGW 'setup expect' '
test_expect_success 'setup expect' '
cat - <<EOF >expect
want $B
want $S
EOF
'
test_expect_success NOT_MINGW 'new clone fetch master and tags' '
test_expect_success 'new clone fetch master and tags' '
git branch -D cat
rm -f $U
(
......@@ -148,7 +146,7 @@ test_expect_success NOT_MINGW 'new clone fetch master and tags' '
cd clone2 &&
git init &&
git remote add origin .. &&
GIT_TRACE_PACKET=3 git fetch 3>../$U &&
GIT_TRACE_PACKET=$UPATH git fetch &&
test $B = $(git rev-parse --verify origin/master) &&
test $S = $(git rev-parse --verify tag2) &&
test $B = $(git rev-parse --verify tag2^0) &&
......
......@@ -54,11 +54,14 @@ cd "$base_dir"
rm -f "$U.D"
test_expect_success 'cloning with reference (no -l -s)' \
'GIT_TRACE_PACKET=3 git clone --reference B "file://$(pwd)/A" D 3>"$U.D"'
test_expect_success 'cloning with reference (no -l -s)' '
GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
'
test_expect_success 'fetched no objects' \
'! grep " want" "$U.D"'
test_expect_success 'fetched no objects' '
test -s "$U.D" &&
! grep " want" "$U.D"
'
cd "$base_dir"
......@@ -173,9 +176,10 @@ test_expect_success 'fetch with incomplete alternates' '
(
cd K &&
git remote add J "file://$base_dir/J" &&
GIT_TRACE_PACKET=3 git fetch J 3>"$U.K"
GIT_TRACE_PACKET=$U.K git fetch J
) &&
master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
test -s "$U.K" &&
! grep " want $master_object" "$U.K" &&
tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
! grep " want $tag_object" "$U.K"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册