Skip to content

Commit 7abcbcb

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c576868 commit 7abcbcb

19 files changed

+53
-50
lines changed

t/t0021-conversion.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ test_expect_success setup '
7676
git config filter.rot13.clean ./rot13.sh &&
7777
7878
{
79-
echo "*.t filter=rot13"
79+
echo "*.t filter=rot13" &&
8080
echo "*.i ident"
8181
} >.gitattributes &&
8282
8383
{
84-
echo a b c d e f g h i j k l m
85-
echo n o p q r s t u v w x y z
84+
echo a b c d e f g h i j k l m &&
85+
echo n o p q r s t u v w x y z &&
8686
echo '\''$Id$'\''
8787
} >test &&
8888
cat test >test.t &&
@@ -159,7 +159,7 @@ test_expect_success expanded_in_repo '
159159
printf "\$Id: NoTerminatingSymbolAtEOF"
160160
} >expected-output-crlf &&
161161
{
162-
echo "expanded-keywords ident"
162+
echo "expanded-keywords ident" &&
163163
echo "expanded-keywords-crlf ident text eol=crlf"
164164
} >>.gitattributes &&
165165

t/t0069-oidtree.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_expect_success 'oidtree insert and contains' '
2828
EOF
2929
{
3030
echoid insert 444 1 2 3 4 5 a b c d e &&
31-
echoid contains 44 441 440 444 4440 4444
31+
echoid contains 44 441 440 444 4440 4444 &&
3232
echo clear
3333
} | test-tool oidtree >actual &&
3434
test_cmp expect actual
@@ -37,11 +37,11 @@ test_expect_success 'oidtree insert and contains' '
3737
test_expect_success 'oidtree each' '
3838
echoid "" 123 321 321 >expect &&
3939
{
40-
echoid insert f 9 8 123 321 a b c d e
41-
echo each 12300
42-
echo each 3211
43-
echo each 3210
44-
echo each 32100
40+
echoid insert f 9 8 123 321 a b c d e &&
41+
echo each 12300 &&
42+
echo each 3211 &&
43+
echo each 3210 &&
44+
echo each 32100 &&
4545
echo clear
4646
} | test-tool oidtree >actual &&
4747
test_cmp expect actual

t/t1006-cat-file.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
283283

284284
test_expect_success 'setup blobs which are likely to delta' '
285285
test-tool genrandom foo 10240 >foo &&
286-
{ cat foo; echo plus; } >foo-plus &&
286+
{ cat foo && echo plus; } >foo-plus &&
287287
git add foo foo-plus &&
288288
git commit -m foo &&
289289
cat >blobs <<-\EOF

t/t1300-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ test_expect_success 'get --expiry-date' '
901901
EOF
902902
: "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" &&
903903
{
904-
echo "$rel_out $(git config --expiry-date date.valid1)"
904+
echo "$rel_out $(git config --expiry-date date.valid1)" &&
905905
git config --expiry-date date.valid2 &&
906906
git config --expiry-date date.valid3 &&
907907
git config --expiry-date date.valid4 &&

t/t1403-show-ref.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test_expect_success 'show-ref --verify -q' '
7878
test_expect_success 'show-ref -d' '
7979
{
8080
echo $(git rev-parse refs/tags/A) refs/tags/A &&
81-
echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}"
81+
echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}" &&
8282
echo $(git rev-parse refs/tags/C) refs/tags/C
8383
} >expect &&
8484
git show-ref -d A C >actual &&
@@ -148,16 +148,16 @@ test_expect_success 'show-ref --heads, --tags, --head, pattern' '
148148
149149
{
150150
echo $(git rev-parse HEAD) HEAD &&
151-
echo $(git rev-parse refs/heads/B) refs/heads/B
151+
echo $(git rev-parse refs/heads/B) refs/heads/B &&
152152
echo $(git rev-parse refs/tags/B) refs/tags/B
153153
} >expect &&
154154
git show-ref --head B >actual &&
155155
test_cmp expect actual &&
156156
157157
{
158158
echo $(git rev-parse HEAD) HEAD &&
159-
echo $(git rev-parse refs/heads/B) refs/heads/B
160-
echo $(git rev-parse refs/tags/B) refs/tags/B
159+
echo $(git rev-parse refs/heads/B) refs/heads/B &&
160+
echo $(git rev-parse refs/tags/B) refs/tags/B &&
161161
echo $(git rev-parse refs/tags/B^0) "refs/tags/B^{}"
162162
} >expect &&
163163
git show-ref --head -d B >actual &&

t/t2200-add-update.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ test_expect_success 'add -u resolves unmerged paths' '
153153
echo "100644 $one 1 $path" &&
154154
echo "100644 $two 2 $path" &&
155155
echo "100644 $three 3 $path"
156-
done
157-
echo "100644 $one 1 path3"
158-
echo "100644 $one 1 path4"
159-
echo "100644 $one 3 path5"
156+
done &&
157+
echo "100644 $one 1 path3" &&
158+
echo "100644 $one 1 path4" &&
159+
echo "100644 $one 3 path5" &&
160160
echo "100644 $one 3 path6"
161161
} |
162162
git update-index --index-info &&
@@ -173,8 +173,8 @@ test_expect_success 'add -u resolves unmerged paths' '
173173
git add -u &&
174174
git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
175175
{
176-
echo "100644 $three 0 path1"
177-
echo "100644 $two 0 path3"
176+
echo "100644 $three 0 path1" &&
177+
echo "100644 $two 0 path3" &&
178178
echo "100644 $two 0 path5"
179179
} >expect &&
180180
test_cmp expect actual

t/t2201-add-update-typechange.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,17 @@ test_expect_success modify '
9797
"
9898
} >expect &&
9999
{
100-
cat expect
101-
echo ":100644 160000 $_empty $ZERO_OID T yonk"
100+
cat expect &&
101+
echo ":100644 160000 $_empty $ZERO_OID T yonk" &&
102102
echo ":100644 000000 $_empty $ZERO_OID D zifmia"
103103
} >expect-files &&
104104
{
105-
cat expect
105+
cat expect &&
106106
echo ":000000 160000 $ZERO_OID $ZERO_OID A yonk"
107107
} >expect-index &&
108108
{
109-
echo "100644 $_empty 0 nitfol"
110-
echo "160000 $yomin 0 yomin"
109+
echo "100644 $_empty 0 nitfol" &&
110+
echo "160000 $yomin 0 yomin" &&
111111
echo "160000 $yonk 0 yonk"
112112
} >expect-final
113113
'

t/t4023-diff-rename-typechange.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ test_expect_success 'cross renames to be detected for regular files' '
5555
5656
git diff-tree five six -r --name-status -B -M | sort >actual &&
5757
{
58-
echo "R100 foo bar"
58+
echo "R100 foo bar" &&
5959
echo "R100 bar foo"
6060
} | sort >expect &&
6161
test_cmp expect actual
@@ -66,7 +66,7 @@ test_expect_success 'cross renames to be detected for typechange' '
6666
6767
git diff-tree one two -r --name-status -B -M | sort >actual &&
6868
{
69-
echo "R100 foo bar"
69+
echo "R100 foo bar" &&
7070
echo "R100 bar foo"
7171
} | sort >expect &&
7272
test_cmp expect actual
@@ -78,7 +78,7 @@ test_expect_success 'moves and renames' '
7878
git diff-tree three four -r --name-status -B -M | sort >actual &&
7979
{
8080
# see -B -M (#6) in t4008
81-
echo "C100 foo bar"
81+
echo "C100 foo bar" &&
8282
echo "T100 foo"
8383
} | sort >expect &&
8484
test_cmp expect actual

t/t4124-apply-ws-rule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ test_expect_success 'blank at EOF with --whitespace=fix (1)' '
233233
test_write_lines a b c >one &&
234234
git add one &&
235235
test_write_lines a b c >expect &&
236-
{ cat expect; echo; } >one &&
236+
{ cat expect && echo; } >one &&
237237
git diff -- one >patch &&
238238
239239
git checkout one &&

t/t4150-am.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ test_expect_success setup '
116116
git format-patch --stdout first | sed -e "1d"
117117
} | append_cr >patch1-crlf.eml &&
118118
{
119-
printf "%255s\\n" ""
119+
printf "%255s\\n" "" &&
120120
echo "X-Fake-Field: Line One" &&
121121
echo "X-Fake-Field: Line Two" &&
122122
echo "X-Fake-Field: Line Three" &&

0 commit comments

Comments
 (0)