diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2022-08-22 21:26:42 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-08-22 22:53:02 +0300 |
commit | 0e66bc1b215b1dd2b0f05c5777eb8ee2ae4e9523 (patch) | |
tree | 12e41d0779a59a42f52889fb94e5607f8a273363 /t/t1092-sparse-checkout-compatibility.sh | |
parent | 625ff5c3201186cedb856678907a3f4bd88406a6 (diff) |
t: detect and signal failure within loop
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. Therefore, detect and signal failures manually within
loops using the idiom `|| return 1` (or `|| exit 1` within subshells).
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1092-sparse-checkout-compatibility.sh')
-rwxr-xr-x | t/t1092-sparse-checkout-compatibility.sh | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index e13368861c..0302e36fd6 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -556,7 +556,7 @@ test_expect_success 'blame with pathspec inside sparse definition' ' deep/deeper1/a \ deep/deeper1/deepest/a do - test_all_match git blame $file + test_all_match git blame $file || return 1 done ' @@ -1571,7 +1571,7 @@ test_expect_success 'sparse index is not expanded: blame' ' deep/deeper1/a \ deep/deeper1/deepest/a do - ensure_not_expanded blame $file + ensure_not_expanded blame $file || return 1 done ' @@ -1907,7 +1907,7 @@ test_expect_success 'rm pathspec outside sparse definition' ' test_sparse_match test_must_fail git rm $file && test_sparse_match test_must_fail git rm --cached $file && test_sparse_match git rm --sparse $file && - test_sparse_match git status --porcelain=v2 + test_sparse_match git status --porcelain=v2 || return 1 done && cat >folder1-full <<-EOF && |