summaryrefslogtreecommitdiff
path: root/t/t4138-apply-ws-expansion.sh
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2021-12-09 05:11:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-13 18:29:48 (GMT)
commitcbe1d9d630e529d3dd240eacf3d1c9799fef702b (patch)
tree5aaa08925285248af953dc01916f33b26d0eb142 /t/t4138-apply-ws-expansion.sh
parentdb5875aa9fe056c2db3a463989091c5f70d6c8d1 (diff)
downloadgit-cbe1d9d630e529d3dd240eacf3d1c9799fef702b.zip
git-cbe1d9d630e529d3dd240eacf3d1c9799fef702b.tar.gz
git-cbe1d9d630e529d3dd240eacf3d1c9799fef702b.tar.bz2
t4000-t4999: 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> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4138-apply-ws-expansion.sh')
-rwxr-xr-xt/t4138-apply-ws-expansion.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh
index 4ba52bb..8bbf826 100755
--- a/t/t4138-apply-ws-expansion.sh
+++ b/t/t4138-apply-ws-expansion.sh
@@ -30,7 +30,7 @@ test_expect_success setup '
while test $x -lt $n
do
printf "%63s%d\n" "" $x >>after &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
printf "\t%s\n" d e f >>after &&
test_expect_code 1 git diff --no-index before after >patch2.patch.raw &&
@@ -41,7 +41,7 @@ test_expect_success setup '
while test $x -lt $n
do
printf "%63s%d\n" "" $x >>expect-2 &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
printf "%64s\n" d e f >>expect-2 &&
@@ -53,7 +53,7 @@ test_expect_success setup '
while test $x -lt $n
do
printf "%63s%02d\n" "" $x >>after &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
printf "\t%s\n" d e f >>after &&
test_expect_code 1 git diff --no-index before after >patch3.patch.raw &&
@@ -64,7 +64,7 @@ test_expect_success setup '
while test $x -lt $n
do
printf "%63s%02d\n" "" $x >>expect-3 &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
printf "%64s\n" d e f >>expect-3 &&
@@ -74,7 +74,7 @@ test_expect_success setup '
while test $x -lt 50
do
printf "\t%02d\n" $x >>before &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
cat before >after &&
printf "%64s\n" a b c >>after &&
@@ -82,7 +82,7 @@ test_expect_success setup '
do
printf "\t%02d\n" $x >>before &&
printf "\t%02d\n" $x >>after &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
test_expect_code 1 git diff --no-index before after >patch4.patch.raw &&
sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch &&
@@ -91,7 +91,7 @@ test_expect_success setup '
while test $x -lt 50
do
printf "%63s%02d\n" "" $x >>test-4 &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
cat test-4 >expect-4 &&
printf "%64s\n" a b c >>expect-4 &&
@@ -99,7 +99,7 @@ test_expect_success setup '
do
printf "%63s%02d\n" "" $x >>test-4 &&
printf "%63s%02d\n" "" $x >>expect-4 &&
- x=$(( $x + 1 ))
+ x=$(( $x + 1 )) || return 1
done &&
git config core.whitespace tab-in-indent,tabwidth=63 &&