diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2021-12-09 06:11:06 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-13 19:29:48 +0100 |
commit | 74d2f5695dab4454097b2d1693f7206e8328724a (patch) | |
tree | 6d4a147a909ef45477fd1509e83530b7ed39bec9 /t/t4138-apply-ws-expansion.sh | |
parent | tests: use test_write_lines() to generate line-oriented output (diff) | |
download | git-74d2f5695dab4454097b2d1693f7206e8328724a.tar.xz git-74d2f5695dab4454097b2d1693f7206e8328724a.zip |
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>
Diffstat (limited to 't/t4138-apply-ws-expansion.sh')
-rwxr-xr-x | t/t4138-apply-ws-expansion.sh | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh 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 && |