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 <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committedDec 9, 2021 at 00:11 UTC74d2f5695dab4454097b2d1693f7206e8328724a
index ff7cfd884a..8c3d48e257 100755--- a/t/t4046-diff-unmerged.sh+++ b/t/t4046-diff-unmerged.sh@@ -18,7 +18,7 @@ test_expect_success setup ' for t in o x do path="$b$o$t" &&- case "$path" in ooo) continue ;; esac+ case "$path" in ooo) continue ;; esac && paths="$paths$path " && p=" $path" && case "$b" in x) echo "$m1$p" ;; esac &&
t/t4123-apply-shrink.sh
+2-2
index 984157f03b..51e69cf79e 100755--- a/t/t4123-apply-shrink.sh+++ b/t/t4123-apply-shrink.sh@@ -45,8 +45,8 @@ test_expect_success 'apply should fail gracefully' ' echo Oops, should not have succeeded false else- status=$?- echo "Status was $status"+ status=$? &&+ echo "Status was $status" && if test -f .git/index.lock then echo Oops, should not have crashed
t/t4138-apply-ws-expansion.sh
+10-10
index b19faeb67a..4ba52bbb61 100755--- a/t/t4138-apply-ws-expansion.sh+++ b/t/t4138-apply-ws-expansion.sh@@ -29,7 +29,7 @@ test_expect_success setup ' x=1 && while test $x -lt $n do- printf "%63s%d\n" "" $x >>after+ printf "%63s%d\n" "" $x >>after && x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after &&@@ -40,7 +40,7 @@ test_expect_success setup ' x=1 && while test $x -lt $n do- printf "%63s%d\n" "" $x >>expect-2+ printf "%63s%d\n" "" $x >>expect-2 && x=$(( $x + 1 )) done && printf "%64s\n" d e f >>expect-2 &&@@ -52,7 +52,7 @@ test_expect_success setup ' x=0 && while test $x -lt $n do- printf "%63s%02d\n" "" $x >>after+ printf "%63s%02d\n" "" $x >>after && x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after &&@@ -63,7 +63,7 @@ test_expect_success setup ' x=0 && while test $x -lt $n do- printf "%63s%02d\n" "" $x >>expect-3+ printf "%63s%02d\n" "" $x >>expect-3 && x=$(( $x + 1 )) done && printf "%64s\n" d e f >>expect-3 &&@@ -73,15 +73,15 @@ test_expect_success setup ' x=0 && while test $x -lt 50 do- printf "\t%02d\n" $x >>before+ printf "\t%02d\n" $x >>before && x=$(( $x + 1 )) done && cat before >after && printf "%64s\n" a b c >>after && while test $x -lt 100 do- printf "\t%02d\n" $x >>before- printf "\t%02d\n" $x >>after+ printf "\t%02d\n" $x >>before &&+ printf "\t%02d\n" $x >>after && x=$(( $x + 1 )) done && test_expect_code 1 git diff --no-index before after >patch4.patch.raw &&@@ -90,15 +90,15 @@ test_expect_success setup ' x=0 && while test $x -lt 50 do- printf "%63s%02d\n" "" $x >>test-4+ printf "%63s%02d\n" "" $x >>test-4 && x=$(( $x + 1 )) done && cat test-4 >expect-4 && printf "%64s\n" a b c >>expect-4 && while test $x -lt 100 do- printf "%63s%02d\n" "" $x >>test-4- printf "%63s%02d\n" "" $x >>expect-4+ printf "%63s%02d\n" "" $x >>test-4 &&+ printf "%63s%02d\n" "" $x >>expect-4 && x=$(( $x + 1 )) done &&
index cf3e82bdf5..23c156e399 100755--- a/t/t5616-partial-clone.sh+++ b/t/t5616-partial-clone.sh@@ -16,9 +16,9 @@ test_expect_success 'setup normal src repo' ' git init src && for n in 1 2 3 4 do- echo "This is file: $n" > src/file.$n.txt- git -C src add file.$n.txt- git -C src commit -m "file $n"+ echo "This is file: $n" > src/file.$n.txt &&+ git -C src add file.$n.txt &&+ git -C src commit -m "file $n" && git -C src ls-files -s file.$n.txt >>temp done && awk -f print_2.awk <temp | sort >expect_1.oids &&@@ -72,8 +72,8 @@ test_expect_success 'push new commits to server' ' git -C src remote add srv "file://$(pwd)/srv.bare" && for x in a b c d e do- echo "Mod file.1.txt $x" >>src/file.1.txt- git -C src add file.1.txt+ echo "Mod file.1.txt $x" >>src/file.1.txt &&+ git -C src add file.1.txt && git -C src commit -m "mod $x" done && git -C src blame main -- file.1.txt >expect.blame &&@@ -114,8 +114,8 @@ test_expect_success 'verify blame causes dynamic object fetch' ' test_expect_success 'push new commits to server for file.2.txt' ' for x in a b c d e f do- echo "Mod file.2.txt $x" >>src/file.2.txt- git -C src add file.2.txt+ echo "Mod file.2.txt $x" >>src/file.2.txt &&+ git -C src add file.2.txt && git -C src commit -m "mod $x" done && git -C src push -u srv main@@ -135,8 +135,8 @@ test_expect_success 'override inherited filter-spec using --no-filter' ' test_expect_success 'push new commits to server for file.3.txt' ' for x in a b c d e f do- echo "Mod file.3.txt $x" >>src/file.3.txt- git -C src add file.3.txt+ echo "Mod file.3.txt $x" >>src/file.3.txt &&+ git -C src add file.3.txt && git -C src commit -m "mod $x" done && git -C src push -u srv main
t/t6005-rev-list-count.sh
+4-4
index 0b64822bf6..2a2083e6bc 100755--- a/t/t6005-rev-list-count.sh+++ b/t/t6005-rev-list-count.sh@@ -5,10 +5,10 @@ test_description='git rev-list --max-count and --skip test' . ./test-lib.sh test_expect_success 'setup' '- for n in 1 2 3 4 5 ; do \- echo $n > a ; \- git add a ; \- git commit -m "$n" ; \+ for n in 1 2 3 4 5 ; do+ echo $n > a &&+ git add a &&+ git commit -m "$n" done '
t/t6009-rev-list-parent.sh
+1-1
index 63fa7c8313..dc8160aa45 100755--- a/t/t6009-rev-list-parent.sh+++ b/t/t6009-rev-list-parent.sh@@ -142,7 +142,7 @@ test_expect_success 'ancestors with the same commit time' ' test_tick_keep=$test_tick && for i in 1 2 3 4 5 6 7 8; do- test_tick=$test_tick_keep+ test_tick=$test_tick_keep && test_commit t$i done && git rev-list t1^! --not t$i >result &&
t/t6112-rev-list-filters-objects.sh
+7-7
index 4ade105db3..9848425192 100755--- a/t/t6112-rev-list-filters-objects.sh+++ b/t/t6112-rev-list-filters-objects.sh@@ -16,8 +16,8 @@ test_expect_success 'setup r1' ' git init r1 && for n in 1 2 3 4 5 do- echo "This is file: $n" > r1/file.$n- git -C r1 add file.$n+ echo "This is file: $n" > r1/file.$n &&+ git -C r1 add file.$n && git -C r1 commit -m "$n" done '@@ -73,8 +73,8 @@ test_expect_success 'setup r2' ' git init r2 && for n in 1000 10000 do- printf "%"$n"s" X > r2/large.$n- git -C r2 add large.$n+ printf "%"$n"s" X > r2/large.$n &&+ git -C r2 add large.$n && git -C r2 commit -m "$n" done '@@ -245,9 +245,9 @@ test_expect_success 'setup r3' ' mkdir r3/dir1 && for n in sparse1 sparse2 do- echo "This is file: $n" > r3/$n- git -C r3 add $n- echo "This is file: dir1/$n" > r3/dir1/$n+ echo "This is file: $n" > r3/$n &&+ git -C r3 add $n &&+ echo "This is file: dir1/$n" > r3/dir1/$n && git -C r3 add dir1/$n done && git -C r3 commit -m "sparse" &&
t/t6120-describe.sh
+5-2
index bae2419150..9b2cc066f7 100755--- a/t/t6120-describe.sh+++ b/t/t6120-describe.sh@@ -390,8 +390,11 @@ test_expect_success ULIMIT_STACK_SIZE 'name-rev works in a deep repo' ' committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 data <<EOF commit #$i-EOF"- test $i = 1 && echo "from refs/heads/main^0"+EOF" &&+ if test $i = 1+ then+ echo "from refs/heads/main^0"+ fi && i=$(($i + 1)) done | git fast-import && git checkout main &&
t/t6407-merge-binary.sh
+2-2
index d4273f2575..4c4f690588 100755--- a/t/t6407-merge-binary.sh+++ b/t/t6407-merge-binary.sh@@ -47,7 +47,7 @@ test_expect_success resolve ' echo Oops, should not have succeeded false else- git ls-files -s >current+ git ls-files -s >current && test_cmp expect current fi '@@ -62,7 +62,7 @@ test_expect_success recursive ' echo Oops, should not have succeeded false else- git ls-files -s >current+ git ls-files -s >current && test_cmp expect current fi '
t/t6412-merge-large-rename.sh
+1-1
index c50d315722..ed40801380 100755--- a/t/t6412-merge-large-rename.sh+++ b/t/t6412-merge-large-rename.sh@@ -47,7 +47,7 @@ test_rename() { git commit -a -m change=$n && git checkout -b test$n HEAD^ && for i in $(count $n); do- git rm $i+ git rm $i && make_text $i initial changed >$i.moved done && git add . &&
t/t7004-tag.sh
+5-2
index 082be85dff..660cde5a63 100755--- a/t/t7004-tag.sh+++ b/t/t7004-tag.sh@@ -1976,8 +1976,11 @@ test_expect_success ULIMIT_STACK_SIZE '--contains and --no-contains work in a de committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200 data <<EOF commit #$i-EOF"- test $i = 1 && echo "from refs/heads/main^0"+EOF" &&+ if test $i = 1+ then+ echo "from refs/heads/main^0"+ fi && i=$(($i + 1)) done | git fast-import && git checkout main &&
t/t7519-status-fsmonitor.sh
+1-1
index f488d930df..1b4160dc53 100755--- a/t/t7519-status-fsmonitor.sh+++ b/t/t7519-status-fsmonitor.sh@@ -248,7 +248,7 @@ do git config core.preloadIndex $preload_val && if test $preload_val = true then- GIT_TEST_PRELOAD_INDEX=$preload_val; export GIT_TEST_PRELOAD_INDEX+ GIT_TEST_PRELOAD_INDEX=$preload_val && export GIT_TEST_PRELOAD_INDEX else sane_unset GIT_TEST_PRELOAD_INDEX fi