From 0849541268a3aca9381591aed87b6864a203709b Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Thu, 9 Dec 2021 00:11:05 -0500 Subject: tests: use test_write_lines() to generate line-oriented output Take advantage of test_write_lines() to generate line-oriented output rather than using for-loops or a series of `echo` commands. Not only is test_write_lines() a natural fit for such a task, but there is less opportunity for a broken &&-chain. Signed-off-by: Eric Sunshine Reviewed-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t5300-pack-object.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 't/t5300-pack-object.sh') diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index e13a884207..f9877d42d7 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -361,11 +361,7 @@ test_expect_success 'unpacking with --strict' ' ST=$(git write-tree) && git rev-list --objects "$LIST" "$LI" "$ST" >actual && PACK5=$( git pack-objects test-5 actual && PACK5=$( git pack-objects test-5 Date: Thu, 9 Dec 2021 00:11:14 -0500 Subject: t5000-t5999: 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 Reviewed-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t5300-pack-object.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/t5300-pack-object.sh') diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index f9877d42d7..2fd845187e 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -347,7 +347,7 @@ test_expect_success 'unpacking with --strict' ' for i in 0 1 2 3 4 5 6 7 8 9 do o=$(echo $j$i | git hash-object -w --stdin) && - echo "100644 $o 0 $j$i" + echo "100644 $o 0 $j$i" || return 1 done done >LIST && rm -f .git/index && @@ -390,7 +390,7 @@ test_expect_success 'index-pack with --strict' ' for i in 0 1 2 3 4 5 6 7 8 9 do o=$(echo $j$i | git hash-object -w --stdin) && - echo "100644 $o 0 $j$i" + echo "100644 $o 0 $j$i" || return 1 done done >LIST && rm -f .git/index && @@ -586,7 +586,7 @@ test_expect_success 'setup for --stdin-packs tests' ' for id in A B C do git pack-objects .git/objects/pack/pack-$id \ - --incremental --revs <<-EOF + --incremental --revs <<-EOF || exit 1 refs/tags/$id EOF done && -- cgit v1.2.3