diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2022-08-28 08:17:58 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-29 19:28:31 +0300 |
commit | 87ed97167a1b1bce41e0380ec6a9507876015e89 (patch) | |
tree | 78045b80852727abc26639cc3ec920ddd1a1d373 | |
parent | bcf325ae775c4e5dab39cd30b16564b7b3d66b80 (diff) |
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 <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | t/t4301-merge-tree-write-tree.sh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh index d44c7767f3..82a104bcbc 100755 --- a/t/t4301-merge-tree-write-tree.sh +++ b/t/t4301-merge-tree-write-tree.sh @@ -150,7 +150,7 @@ test_expect_success 'directory rename + content conflict' ' cd dir-rename-and-content && test_write_lines 1 2 3 4 5 >foo && mkdir olddir && - for i in a b c; do echo $i >olddir/$i; done + for i in a b c; do echo $i >olddir/$i || exit 1; done && git add foo olddir && git commit -m "original" && @@ -662,7 +662,7 @@ test_expect_success 'directory rename + rename/delete + modify/delete + director cd 4-stacked-conflict && test_write_lines 1 2 3 4 5 >foo && mkdir olddir && - for i in a b c; do echo $i >olddir/$i; done + for i in a b c; do echo $i >olddir/$i || exit 1; done && git add foo olddir && git commit -m "original" && |