Skip to content

Commit 87ed971

Browse files
sunshinecogitster
authored andcommitted
t4301: fix broken &&-chains and add missing loop termination
Fix &&-chain breaks in a couple tests which went unnoticed due to blind spots in the &&-chain linters. In particular, the "magic exit code 117" &&-chain checker built into test-lib.sh only recognizes broken &&-chains at the top-level; it does not work within `{...}` groups, `(...)` subshells, `$(...)` substitutions, or within bodies of compound statements, such as `if`, `for`, `while`, `case`, etc. Furthermore, `chainlint.sed`, which detects broken &&-chains only in `(...)` subshells, missed these cases (which are in subshells) because it (surprisingly) neglects to check for intact &&-chain on single-line `for` loops. While at it, explicitly signal failure of commands within the `for` loops (which might arise due to the filesystem being full or "inode" exhaustion). This is important since failures within `for` and `while` loops can go unnoticed if not detected and signaled manually since the loop itself does not abort when a contained command fails, nor will a failure necessarily be detected when the loop finishes since the loop returns the exit code of the last command it ran on the final iteration, which may not be the command which failed. Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bcf325a commit 87ed971

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

t/t4301-merge-tree-write-tree.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ test_expect_success 'directory rename + content conflict' '
150150
cd dir-rename-and-content &&
151151
test_write_lines 1 2 3 4 5 >foo &&
152152
mkdir olddir &&
153-
for i in a b c; do echo $i >olddir/$i; done
153+
for i in a b c; do echo $i >olddir/$i || exit 1; done &&
154154
git add foo olddir &&
155155
git commit -m "original" &&
156156
@@ -662,7 +662,7 @@ test_expect_success 'directory rename + rename/delete + modify/delete + director
662662
cd 4-stacked-conflict &&
663663
test_write_lines 1 2 3 4 5 >foo &&
664664
mkdir olddir &&
665-
for i in a b c; do echo $i >olddir/$i; done
665+
for i in a b c; do echo $i >olddir/$i || exit 1; done &&
666666
git add foo olddir &&
667667
git commit -m "original" &&
668668

0 commit comments

Comments
 (0)