Skip to content

Commit 74d2f56

Browse files
sunshinecogitster
authored andcommitted
tests: fix broken &&-chains in compound statements
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 compound statements in order to reduce the number of possible lurking bugs. Signed-off-by: Eric Sunshine <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0849541 commit 74d2f56

28 files changed

+95
-89
lines changed

t/perf/p0005-status.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ test_perf_default_repo
2424
test_expect_success "setup repo" '
2525
if git rev-parse --verify refs/heads/p0006-ballast^{commit}
2626
then
27-
echo Assuming synthetic repo from many-files.sh
28-
git branch br_base master
29-
git branch br_ballast p0006-ballast
30-
git config --local core.sparsecheckout 1
27+
echo Assuming synthetic repo from many-files.sh &&
28+
git branch br_base master &&
29+
git branch br_ballast p0006-ballast &&
30+
git config --local core.sparsecheckout 1 &&
3131
cat >.git/info/sparse-checkout <<-EOF
3232
/*
3333
!ballast/*
3434
EOF
3535
else
36-
echo Assuming non-synthetic repo...
37-
git branch br_base $(git rev-list HEAD | tail -n 1)
36+
echo Assuming non-synthetic repo... &&
37+
git branch br_base $(git rev-list HEAD | tail -n 1) &&
3838
git branch br_ballast HEAD
3939
fi &&
4040
git checkout -q br_ballast &&

t/perf/p0006-read-tree-checkout.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ test_perf_default_repo
2424
test_expect_success "setup repo" '
2525
if git rev-parse --verify refs/heads/p0006-ballast^{commit}
2626
then
27-
echo Assuming synthetic repo from many-files.sh
28-
git branch br_base master
29-
git branch br_ballast p0006-ballast^
30-
git branch br_ballast_alias p0006-ballast^
31-
git branch br_ballast_plus_1 p0006-ballast
32-
git config --local core.sparsecheckout 1
27+
echo Assuming synthetic repo from many-files.sh &&
28+
git branch br_base master &&
29+
git branch br_ballast p0006-ballast^ &&
30+
git branch br_ballast_alias p0006-ballast^ &&
31+
git branch br_ballast_plus_1 p0006-ballast &&
32+
git config --local core.sparsecheckout 1 &&
3333
cat >.git/info/sparse-checkout <<-EOF
3434
/*
3535
!ballast/*
3636
EOF
3737
else
38-
echo Assuming non-synthetic repo...
39-
git branch br_base $(git rev-list HEAD | tail -n 1)
40-
git branch br_ballast HEAD^ || error "no ancestor commit from current head"
41-
git branch br_ballast_alias HEAD^
38+
echo Assuming non-synthetic repo... &&
39+
git branch br_base $(git rev-list HEAD | tail -n 1) &&
40+
git branch br_ballast HEAD^ || error "no ancestor commit from current head" &&
41+
git branch br_ballast_alias HEAD^ &&
4242
git branch br_ballast_plus_1 HEAD
4343
fi &&
4444
git checkout -q br_ballast &&

t/perf/p0007-write-cache.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ test_perf_default_repo
99
test_expect_success "setup repo" '
1010
if git rev-parse --verify refs/heads/p0006-ballast^{commit}
1111
then
12-
echo Assuming synthetic repo from many-files.sh
13-
git config --local core.sparsecheckout 1
12+
echo Assuming synthetic repo from many-files.sh &&
13+
git config --local core.sparsecheckout 1 &&
1414
cat >.git/info/sparse-checkout <<-EOF
1515
/*
1616
!ballast/*

t/perf/p5302-pack-index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_expect_success 'set up thread-counting tests' '
2121
threads= &&
2222
while test $t -gt 0
2323
do
24-
threads="$t $threads"
24+
threads="$t $threads" &&
2525
t=$((t / 2))
2626
done
2727
'

t/perf/p5303-many-packs.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ done
126126
# Measure pack loading with 10,000 packs.
127127
test_expect_success 'generate lots of packs' '
128128
for i in $(test_seq 10000); do
129-
echo "blob"
130-
echo "data <<EOF"
131-
echo "blob $i"
132-
echo "EOF"
129+
echo "blob" &&
130+
echo "data <<EOF" &&
131+
echo "blob $i" &&
132+
echo "EOF" &&
133133
echo "checkpoint"
134134
done |
135135
git -c fastimport.unpackLimit=0 fast-import

t/t1050-large.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ test_expect_success 'add a large file or two' '
5454
bad= count=0 idx= &&
5555
for p in .git/objects/pack/pack-*.pack
5656
do
57-
count=$(( $count + 1 ))
57+
count=$(( $count + 1 )) &&
5858
if test_path_is_file "$p" &&
5959
idx=${p%.pack}.idx && test_path_is_file "$idx"
6060
then
@@ -78,7 +78,7 @@ test_expect_success 'add a large file or two' '
7878
bad= count=0 &&
7979
for p in .git/objects/pack/pack-*.pack
8080
do
81-
count=$(( $count + 1 ))
81+
count=$(( $count + 1 )) &&
8282
if test_path_is_file "$p" &&
8383
idx=${p%.pack}.idx && test_path_is_file "$idx"
8484
then

t/t1300-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ test_expect_success bool '
717717
rm -f result &&
718718
for i in 1 2 3 4
719719
do
720-
git config --bool --get bool.true$i >>result
720+
git config --bool --get bool.true$i >>result &&
721721
git config --bool --get bool.false$i >>result
722722
done &&
723723
test_cmp expect result'

t/t1700-split-index.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ test_expect_success 'enable split index' '
4848
# NEEDSWORK: Stop hard-coding checksums.
4949
if test "$indexversion" = "4"
5050
then
51-
own=$(test_oid own_v4)
51+
own=$(test_oid own_v4) &&
5252
base=$(test_oid base_v4)
5353
else
54-
own=$(test_oid own_v3)
54+
own=$(test_oid own_v3) &&
5555
base=$(test_oid base_v3)
5656
fi &&
5757

t/t2200-add-update.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ test_expect_success 'add -u resolves unmerged paths' '
150150
{
151151
for path in path1 path2
152152
do
153-
echo "100644 $one 1 $path"
154-
echo "100644 $two 2 $path"
153+
echo "100644 $one 1 $path" &&
154+
echo "100644 $two 2 $path" &&
155155
echo "100644 $three 3 $path"
156156
done
157157
echo "100644 $one 1 path3"

t/t3070-wildmatch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ match() {
193193
file=$(cat .git/expected_test_file) &&
194194
if should_create_test_file "$file"
195195
then
196-
dirs=${file%/*}
196+
dirs=${file%/*} &&
197197
if test "$file" != "$dirs"
198198
then
199199
mkdir -p -- "$dirs" &&

0 commit comments

Comments
 (0)