tests: fix broken &&-chains in {...}
groups
The top-level &&-chain checker built into t/test-lib.sh causes tests to magically exit with code 117 if the &&-chain is broken. However, it has the shortcoming that the magic does not work within `{...}` groups, `(...)` subshells, `$(...)` substitutions, or within bodies of compound statements, such as `if`, `for`, `while`, `case`, etc. `chainlint.sed` partly fills in the gap by catching broken &&-chains in `(...)` subshells, but bugs can still lurk behind broken &&-chains in the other cases. Fix broken &&-chains in `{...}` groups in order to reduce the number of possible lurking bugs. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
c576868eaf
commit
7abcbcb7ea
@ -76,13 +76,13 @@ test_expect_success setup '
|
|||||||
git config filter.rot13.clean ./rot13.sh &&
|
git config filter.rot13.clean ./rot13.sh &&
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "*.t filter=rot13"
|
echo "*.t filter=rot13" &&
|
||||||
echo "*.i ident"
|
echo "*.i ident"
|
||||||
} >.gitattributes &&
|
} >.gitattributes &&
|
||||||
|
|
||||||
{
|
{
|
||||||
echo a b c d e f g h i j k l m
|
echo a b c d e f g h i j k l m &&
|
||||||
echo n o p q r s t u v w x y z
|
echo n o p q r s t u v w x y z &&
|
||||||
echo '\''$Id$'\''
|
echo '\''$Id$'\''
|
||||||
} >test &&
|
} >test &&
|
||||||
cat test >test.t &&
|
cat test >test.t &&
|
||||||
@ -159,7 +159,7 @@ test_expect_success expanded_in_repo '
|
|||||||
printf "\$Id: NoTerminatingSymbolAtEOF"
|
printf "\$Id: NoTerminatingSymbolAtEOF"
|
||||||
} >expected-output-crlf &&
|
} >expected-output-crlf &&
|
||||||
{
|
{
|
||||||
echo "expanded-keywords ident"
|
echo "expanded-keywords ident" &&
|
||||||
echo "expanded-keywords-crlf ident text eol=crlf"
|
echo "expanded-keywords-crlf ident text eol=crlf"
|
||||||
} >>.gitattributes &&
|
} >>.gitattributes &&
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ test_expect_success 'oidtree insert and contains' '
|
|||||||
EOF
|
EOF
|
||||||
{
|
{
|
||||||
echoid insert 444 1 2 3 4 5 a b c d e &&
|
echoid insert 444 1 2 3 4 5 a b c d e &&
|
||||||
echoid contains 44 441 440 444 4440 4444
|
echoid contains 44 441 440 444 4440 4444 &&
|
||||||
echo clear
|
echo clear
|
||||||
} | test-tool oidtree >actual &&
|
} | test-tool oidtree >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
@ -37,11 +37,11 @@ test_expect_success 'oidtree insert and contains' '
|
|||||||
test_expect_success 'oidtree each' '
|
test_expect_success 'oidtree each' '
|
||||||
echoid "" 123 321 321 >expect &&
|
echoid "" 123 321 321 >expect &&
|
||||||
{
|
{
|
||||||
echoid insert f 9 8 123 321 a b c d e
|
echoid insert f 9 8 123 321 a b c d e &&
|
||||||
echo each 12300
|
echo each 12300 &&
|
||||||
echo each 3211
|
echo each 3211 &&
|
||||||
echo each 3210
|
echo each 3210 &&
|
||||||
echo each 32100
|
echo each 32100 &&
|
||||||
echo clear
|
echo clear
|
||||||
} | test-tool oidtree >actual &&
|
} | test-tool oidtree >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
@ -283,7 +283,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
|
|||||||
|
|
||||||
test_expect_success 'setup blobs which are likely to delta' '
|
test_expect_success 'setup blobs which are likely to delta' '
|
||||||
test-tool genrandom foo 10240 >foo &&
|
test-tool genrandom foo 10240 >foo &&
|
||||||
{ cat foo; echo plus; } >foo-plus &&
|
{ cat foo && echo plus; } >foo-plus &&
|
||||||
git add foo foo-plus &&
|
git add foo foo-plus &&
|
||||||
git commit -m foo &&
|
git commit -m foo &&
|
||||||
cat >blobs <<-\EOF
|
cat >blobs <<-\EOF
|
||||||
|
@ -901,7 +901,7 @@ test_expect_success 'get --expiry-date' '
|
|||||||
EOF
|
EOF
|
||||||
: "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
|
: "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
|
||||||
{
|
{
|
||||||
echo "$rel_out $(git config --expiry-date date.valid1)"
|
echo "$rel_out $(git config --expiry-date date.valid1)" &&
|
||||||
git config --expiry-date date.valid2 &&
|
git config --expiry-date date.valid2 &&
|
||||||
git config --expiry-date date.valid3 &&
|
git config --expiry-date date.valid3 &&
|
||||||
git config --expiry-date date.valid4 &&
|
git config --expiry-date date.valid4 &&
|
||||||
|
@ -78,7 +78,7 @@ test_expect_success 'show-ref --verify -q' '
|
|||||||
test_expect_success 'show-ref -d' '
|
test_expect_success 'show-ref -d' '
|
||||||
{
|
{
|
||||||
echo $(git rev-parse refs/tags/A) refs/tags/A &&
|
echo $(git rev-parse refs/tags/A) refs/tags/A &&
|
||||||
echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}"
|
echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}" &&
|
||||||
echo $(git rev-parse refs/tags/C) refs/tags/C
|
echo $(git rev-parse refs/tags/C) refs/tags/C
|
||||||
} >expect &&
|
} >expect &&
|
||||||
git show-ref -d A C >actual &&
|
git show-ref -d A C >actual &&
|
||||||
@ -148,7 +148,7 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
|
|||||||
|
|
||||||
{
|
{
|
||||||
echo $(git rev-parse HEAD) HEAD &&
|
echo $(git rev-parse HEAD) HEAD &&
|
||||||
echo $(git rev-parse refs/heads/B) refs/heads/B
|
echo $(git rev-parse refs/heads/B) refs/heads/B &&
|
||||||
echo $(git rev-parse refs/tags/B) refs/tags/B
|
echo $(git rev-parse refs/tags/B) refs/tags/B
|
||||||
} >expect &&
|
} >expect &&
|
||||||
git show-ref --head B >actual &&
|
git show-ref --head B >actual &&
|
||||||
@ -156,8 +156,8 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
|
|||||||
|
|
||||||
{
|
{
|
||||||
echo $(git rev-parse HEAD) HEAD &&
|
echo $(git rev-parse HEAD) HEAD &&
|
||||||
echo $(git rev-parse refs/heads/B) refs/heads/B
|
echo $(git rev-parse refs/heads/B) refs/heads/B &&
|
||||||
echo $(git rev-parse refs/tags/B) refs/tags/B
|
echo $(git rev-parse refs/tags/B) refs/tags/B &&
|
||||||
echo $(git rev-parse refs/tags/B^0) "refs/tags/B^{}"
|
echo $(git rev-parse refs/tags/B^0) "refs/tags/B^{}"
|
||||||
} >expect &&
|
} >expect &&
|
||||||
git show-ref --head -d B >actual &&
|
git show-ref --head -d B >actual &&
|
||||||
|
@ -153,10 +153,10 @@ test_expect_success 'add -u resolves unmerged paths' '
|
|||||||
echo "100644 $one 1 $path" &&
|
echo "100644 $one 1 $path" &&
|
||||||
echo "100644 $two 2 $path" &&
|
echo "100644 $two 2 $path" &&
|
||||||
echo "100644 $three 3 $path"
|
echo "100644 $three 3 $path"
|
||||||
done
|
done &&
|
||||||
echo "100644 $one 1 path3"
|
echo "100644 $one 1 path3" &&
|
||||||
echo "100644 $one 1 path4"
|
echo "100644 $one 1 path4" &&
|
||||||
echo "100644 $one 3 path5"
|
echo "100644 $one 3 path5" &&
|
||||||
echo "100644 $one 3 path6"
|
echo "100644 $one 3 path6"
|
||||||
} |
|
} |
|
||||||
git update-index --index-info &&
|
git update-index --index-info &&
|
||||||
@ -173,8 +173,8 @@ test_expect_success 'add -u resolves unmerged paths' '
|
|||||||
git add -u &&
|
git add -u &&
|
||||||
git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
|
git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
|
||||||
{
|
{
|
||||||
echo "100644 $three 0 path1"
|
echo "100644 $three 0 path1" &&
|
||||||
echo "100644 $two 0 path3"
|
echo "100644 $two 0 path3" &&
|
||||||
echo "100644 $two 0 path5"
|
echo "100644 $two 0 path5"
|
||||||
} >expect &&
|
} >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
@ -97,17 +97,17 @@ test_expect_success modify '
|
|||||||
"
|
"
|
||||||
} >expect &&
|
} >expect &&
|
||||||
{
|
{
|
||||||
cat expect
|
cat expect &&
|
||||||
echo ":100644 160000 $_empty $ZERO_OID T yonk"
|
echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
|
||||||
echo ":100644 000000 $_empty $ZERO_OID D zifmia"
|
echo ":100644 000000 $_empty $ZERO_OID D zifmia"
|
||||||
} >expect-files &&
|
} >expect-files &&
|
||||||
{
|
{
|
||||||
cat expect
|
cat expect &&
|
||||||
echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
|
echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
|
||||||
} >expect-index &&
|
} >expect-index &&
|
||||||
{
|
{
|
||||||
echo "100644 $_empty 0 nitfol"
|
echo "100644 $_empty 0 nitfol" &&
|
||||||
echo "160000 $yomin 0 yomin"
|
echo "160000 $yomin 0 yomin" &&
|
||||||
echo "160000 $yonk 0 yonk"
|
echo "160000 $yonk 0 yonk"
|
||||||
} >expect-final
|
} >expect-final
|
||||||
'
|
'
|
||||||
|
@ -55,7 +55,7 @@ test_expect_success 'cross renames to be detected for regular files' '
|
|||||||
|
|
||||||
git diff-tree five six -r --name-status -B -M | sort >actual &&
|
git diff-tree five six -r --name-status -B -M | sort >actual &&
|
||||||
{
|
{
|
||||||
echo "R100 foo bar"
|
echo "R100 foo bar" &&
|
||||||
echo "R100 bar foo"
|
echo "R100 bar foo"
|
||||||
} | sort >expect &&
|
} | sort >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
@ -66,7 +66,7 @@ test_expect_success 'cross renames to be detected for typechange' '
|
|||||||
|
|
||||||
git diff-tree one two -r --name-status -B -M | sort >actual &&
|
git diff-tree one two -r --name-status -B -M | sort >actual &&
|
||||||
{
|
{
|
||||||
echo "R100 foo bar"
|
echo "R100 foo bar" &&
|
||||||
echo "R100 bar foo"
|
echo "R100 bar foo"
|
||||||
} | sort >expect &&
|
} | sort >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
@ -78,7 +78,7 @@ test_expect_success 'moves and renames' '
|
|||||||
git diff-tree three four -r --name-status -B -M | sort >actual &&
|
git diff-tree three four -r --name-status -B -M | sort >actual &&
|
||||||
{
|
{
|
||||||
# see -B -M (#6) in t4008
|
# see -B -M (#6) in t4008
|
||||||
echo "C100 foo bar"
|
echo "C100 foo bar" &&
|
||||||
echo "T100 foo"
|
echo "T100 foo"
|
||||||
} | sort >expect &&
|
} | sort >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
|
@ -233,7 +233,7 @@ test_expect_success 'blank at EOF with --whitespace=fix (1)' '
|
|||||||
test_write_lines a b c >one &&
|
test_write_lines a b c >one &&
|
||||||
git add one &&
|
git add one &&
|
||||||
test_write_lines a b c >expect &&
|
test_write_lines a b c >expect &&
|
||||||
{ cat expect; echo; } >one &&
|
{ cat expect && echo; } >one &&
|
||||||
git diff -- one >patch &&
|
git diff -- one >patch &&
|
||||||
|
|
||||||
git checkout one &&
|
git checkout one &&
|
||||||
|
@ -116,7 +116,7 @@ test_expect_success setup '
|
|||||||
git format-patch --stdout first | sed -e "1d"
|
git format-patch --stdout first | sed -e "1d"
|
||||||
} | append_cr >patch1-crlf.eml &&
|
} | append_cr >patch1-crlf.eml &&
|
||||||
{
|
{
|
||||||
printf "%255s\\n" ""
|
printf "%255s\\n" "" &&
|
||||||
echo "X-Fake-Field: Line One" &&
|
echo "X-Fake-Field: Line One" &&
|
||||||
echo "X-Fake-Field: Line Two" &&
|
echo "X-Fake-Field: Line Two" &&
|
||||||
echo "X-Fake-Field: Line Three" &&
|
echo "X-Fake-Field: Line Three" &&
|
||||||
|
@ -20,10 +20,10 @@ test_expect_success 'fsck notices broken commit' '
|
|||||||
|
|
||||||
test_expect_success 'git log with broken author email' '
|
test_expect_success 'git log with broken author email' '
|
||||||
{
|
{
|
||||||
echo commit $(cat broken_email.hash)
|
echo commit $(cat broken_email.hash) &&
|
||||||
echo "Author: A U Thor <author@example.com>"
|
echo "Author: A U Thor <author@example.com>" &&
|
||||||
echo "Date: Thu Apr 7 15:13:13 2005 -0700"
|
echo "Date: Thu Apr 7 15:13:13 2005 -0700" &&
|
||||||
echo
|
echo &&
|
||||||
echo " foo"
|
echo " foo"
|
||||||
} >expect.out &&
|
} >expect.out &&
|
||||||
|
|
||||||
|
@ -57,8 +57,11 @@ test_expect_success 'create series of packs' '
|
|||||||
git commit -m $i &&
|
git commit -m $i &&
|
||||||
cur=$(git rev-parse HEAD^{tree}) &&
|
cur=$(git rev-parse HEAD^{tree}) &&
|
||||||
{
|
{
|
||||||
test -n "$prev" && echo "-$prev"
|
if test -n "$prev"
|
||||||
echo $cur
|
then
|
||||||
|
echo "-$prev"
|
||||||
|
fi &&
|
||||||
|
echo $cur &&
|
||||||
echo "$(git rev-parse :file) file"
|
echo "$(git rev-parse :file) file"
|
||||||
} | git pack-objects --stdout >tmp &&
|
} | git pack-objects --stdout >tmp &&
|
||||||
git index-pack --stdin --fix-thin <tmp || return 1
|
git index-pack --stdin --fix-thin <tmp || return 1
|
||||||
|
@ -71,7 +71,7 @@ test_expect_success "fetch test for-merge" '
|
|||||||
main_in_two=$(cd ../two && git rev-parse main) &&
|
main_in_two=$(cd ../two && git rev-parse main) &&
|
||||||
one_in_two=$(cd ../two && git rev-parse one) &&
|
one_in_two=$(cd ../two && git rev-parse one) &&
|
||||||
{
|
{
|
||||||
echo "$one_in_two "
|
echo "$one_in_two " &&
|
||||||
echo "$main_in_two not-for-merge"
|
echo "$main_in_two not-for-merge"
|
||||||
} >expected &&
|
} >expected &&
|
||||||
cut -f -2 .git/FETCH_HEAD >actual &&
|
cut -f -2 .git/FETCH_HEAD >actual &&
|
||||||
|
@ -191,17 +191,17 @@ do
|
|||||||
cp "$expect_r" expect_r &&
|
cp "$expect_r" expect_r &&
|
||||||
convert_expected expect_r sed_script &&
|
convert_expected expect_r sed_script &&
|
||||||
{
|
{
|
||||||
echo "# $cmd"
|
echo "# $cmd" &&
|
||||||
set x $cmd; shift
|
set x $cmd && shift &&
|
||||||
git symbolic-ref HEAD refs/heads/$1 ; shift
|
git symbolic-ref HEAD refs/heads/$1 && shift &&
|
||||||
rm -f .git/FETCH_HEAD
|
rm -f .git/FETCH_HEAD &&
|
||||||
git for-each-ref \
|
git for-each-ref \
|
||||||
refs/heads refs/remotes/rem refs/tags |
|
refs/heads refs/remotes/rem refs/tags |
|
||||||
while read val type refname
|
while read val type refname
|
||||||
do
|
do
|
||||||
git update-ref -d "$refname" "$val"
|
git update-ref -d "$refname" "$val"
|
||||||
done
|
done &&
|
||||||
git fetch "$@" >/dev/null
|
git fetch "$@" >/dev/null &&
|
||||||
cat .git/FETCH_HEAD
|
cat .git/FETCH_HEAD
|
||||||
} >"$actual_f" &&
|
} >"$actual_f" &&
|
||||||
git show-ref >"$actual_r" &&
|
git show-ref >"$actual_r" &&
|
||||||
|
@ -63,7 +63,7 @@ test_expect_success 'setup' '
|
|||||||
hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) &&
|
hash_next=$(git commit-tree -p HEAD -m next HEAD^{tree}) &&
|
||||||
{
|
{
|
||||||
printf "%s %s refs/heads/newbranch\\0report-status object-format=%s\\n" \
|
printf "%s %s refs/heads/newbranch\\0report-status object-format=%s\\n" \
|
||||||
"$ZERO_OID" "$hash_next" "$(test_oid algo)" | packetize_raw
|
"$ZERO_OID" "$hash_next" "$(test_oid algo)" | packetize_raw &&
|
||||||
printf 0000 &&
|
printf 0000 &&
|
||||||
echo "$hash_next" | git pack-objects --stdout
|
echo "$hash_next" | git pack-objects --stdout
|
||||||
} >push_body &&
|
} >push_body &&
|
||||||
|
@ -194,7 +194,7 @@ test_expect_success 'hostname cannot break out of directory' '
|
|||||||
|
|
||||||
test_expect_success FAKENC 'hostname interpolation works after LF-stripping' '
|
test_expect_success FAKENC 'hostname interpolation works after LF-stripping' '
|
||||||
{
|
{
|
||||||
printf "git-upload-pack /interp.git\n\0host=localhost" | packetize_raw
|
printf "git-upload-pack /interp.git\n\0host=localhost" | packetize_raw &&
|
||||||
printf "0000"
|
printf "0000"
|
||||||
} >input &&
|
} >input &&
|
||||||
fake_nc "$GIT_DAEMON_HOST_PORT" <input >output &&
|
fake_nc "$GIT_DAEMON_HOST_PORT" <input >output &&
|
||||||
|
@ -114,7 +114,7 @@ test_expect_success 'push to URL' '
|
|||||||
|
|
||||||
test_expect_success 'set up many-ref tests' '
|
test_expect_success 'set up many-ref tests' '
|
||||||
{
|
{
|
||||||
nr=1000
|
nr=1000 &&
|
||||||
while test $nr -lt 2000
|
while test $nr -lt 2000
|
||||||
do
|
do
|
||||||
nr=$(( $nr + 1 )) &&
|
nr=$(( $nr + 1 )) &&
|
||||||
|
@ -156,7 +156,7 @@ test_expect_success 'with config option on the command line' '
|
|||||||
Acked-by: Johan
|
Acked-by: Johan
|
||||||
Reviewed-by: Peff
|
Reviewed-by: Peff
|
||||||
EOF
|
EOF
|
||||||
{ echo; echo "Acked-by: Johan"; } |
|
{ echo && echo "Acked-by: Johan"; } |
|
||||||
git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
|
git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \
|
||||||
--trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
|
--trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
|
@ -97,7 +97,7 @@ test_expect_success 'set up abbrev tests' '
|
|||||||
test_commit abbrev &&
|
test_commit abbrev &&
|
||||||
sha1=$(git rev-parse --verify HEAD) &&
|
sha1=$(git rev-parse --verify HEAD) &&
|
||||||
check_abbrev () {
|
check_abbrev () {
|
||||||
expect=$1; shift
|
expect=$1 && shift &&
|
||||||
echo $sha1 | cut -c 1-$expect >expect &&
|
echo $sha1 | cut -c 1-$expect >expect &&
|
||||||
git blame "$@" abbrev.t >actual &&
|
git blame "$@" abbrev.t >actual &&
|
||||||
perl -lne "/[0-9a-f]+/ and print \$&" <actual >actual.sha &&
|
perl -lne "/[0-9a-f]+/ and print \$&" <actual >actual.sha &&
|
||||||
|
Reference in New Issue
Block a user