diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2021-12-09 05:11:12 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-13 18:29:48 (GMT) |
commit | db5875aa9fe056c2db3a463989091c5f70d6c8d1 (patch) | |
tree | 7009932d4396e0928ca5926ac985e30f1dcce33a /t/perf | |
parent | efe26b9ee09d53dda0f36d0ea20cb245b934f216 (diff) | |
download | git-db5875aa9fe056c2db3a463989091c5f70d6c8d1.zip git-db5875aa9fe056c2db3a463989091c5f70d6c8d1.tar.gz git-db5875aa9fe056c2db3a463989091c5f70d6c8d1.tar.bz2 |
t0000-t3999: 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/perf')
-rwxr-xr-x | t/perf/p0100-globbing.sh | 4 | ||||
-rwxr-xr-x | t/perf/p1400-update-ref.sh | 4 | ||||
-rwxr-xr-x | t/perf/p1451-fsck-skip-list.sh | 2 | ||||
-rwxr-xr-x | t/perf/p3400-rebase.sh | 2 | ||||
-rwxr-xr-x | t/perf/p5302-pack-index.sh | 2 | ||||
-rwxr-xr-x | t/perf/p5303-many-packs.sh | 2 | ||||
-rwxr-xr-x | t/perf/p7519-fsmonitor.sh | 8 |
7 files changed, 12 insertions, 12 deletions
diff --git a/t/perf/p0100-globbing.sh b/t/perf/p0100-globbing.sh index dd18a9c..439e9c8 100755 --- a/t/perf/p0100-globbing.sh +++ b/t/perf/p0100-globbing.sh @@ -19,9 +19,9 @@ test_expect_success 'setup' ' printf "a" >>refname && for j in $(test_seq 1 $i) do - printf "a*" >>refglob.$i + printf "a*" >>refglob.$i || return 1 done && - echo b >>refglob.$i + echo b >>refglob.$i || return 1 done && test_commit test $(cat refname).t "" $(cat refname).t ' diff --git a/t/perf/p1400-update-ref.sh b/t/perf/p1400-update-ref.sh index dda8a74..a75969c 100755 --- a/t/perf/p1400-update-ref.sh +++ b/t/perf/p1400-update-ref.sh @@ -13,7 +13,7 @@ test_expect_success "setup" ' do printf "start\ncreate refs/heads/%d PRE\ncommit\n" $i && printf "start\nupdate refs/heads/%d POST PRE\ncommit\n" $i && - printf "start\ndelete refs/heads/%d POST\ncommit\n" $i + printf "start\ndelete refs/heads/%d POST\ncommit\n" $i || return 1 done >instructions ' @@ -22,7 +22,7 @@ test_perf "update-ref" ' do git update-ref refs/heads/branch PRE && git update-ref refs/heads/branch POST PRE && - git update-ref -d refs/heads/branch + git update-ref -d refs/heads/branch || return 1 done ' diff --git a/t/perf/p1451-fsck-skip-list.sh b/t/perf/p1451-fsck-skip-list.sh index c2b97d2..f767d83 100755 --- a/t/perf/p1451-fsck-skip-list.sh +++ b/t/perf/p1451-fsck-skip-list.sh @@ -15,7 +15,7 @@ test_expect_success "setup $n bad commits" ' echo "committer C <c@example.com> 1234567890 +0000" && echo "data <<EOF" && echo "$i.Q." && - echo "EOF" + echo "EOF" || return 1 done | q_to_nul | git fast-import ' diff --git a/t/perf/p3400-rebase.sh b/t/perf/p3400-rebase.sh index 43d5a34..e6b0277 100755 --- a/t/perf/p3400-rebase.sh +++ b/t/perf/p3400-rebase.sh @@ -22,7 +22,7 @@ test_expect_success 'setup rebasing on top of a lot of changes' ' git add unrelated-file$i && test_tick && git commit -m commit$i-reverse unrelated-file$i || - break + return 1 done && git checkout to-rebase && test_commit our-patch interesting-file diff --git a/t/perf/p5302-pack-index.sh b/t/perf/p5302-pack-index.sh index 654cd9c..c16f6a3 100755 --- a/t/perf/p5302-pack-index.sh +++ b/t/perf/p5302-pack-index.sh @@ -22,7 +22,7 @@ test_expect_success 'set up thread-counting tests' ' while test $t -gt 0 do threads="$t $threads" && - t=$((t / 2)) + t=$((t / 2)) || return 1 done ' diff --git a/t/perf/p5303-many-packs.sh b/t/perf/p5303-many-packs.sh index 58213fe..af173a7 100755 --- a/t/perf/p5303-many-packs.sh +++ b/t/perf/p5303-many-packs.sh @@ -130,7 +130,7 @@ test_expect_success 'generate lots of packs' ' echo "data <<EOF" && echo "blob $i" && echo "EOF" && - echo "checkpoint" + echo "checkpoint" || return 1 done | git -c fastimport.unpackLimit=0 fast-import ' diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh index 5eb5044..c8be58f 100755 --- a/t/perf/p7519-fsmonitor.sh +++ b/t/perf/p7519-fsmonitor.sh @@ -119,10 +119,10 @@ test_expect_success "one time repo setup" ' fi && mkdir 1_file 10_files 100_files 1000_files 10000_files && - for i in $(test_seq 1 10); do touch 10_files/$i; done && - for i in $(test_seq 1 100); do touch 100_files/$i; done && - for i in $(test_seq 1 1000); do touch 1000_files/$i; done && - for i in $(test_seq 1 10000); do touch 10000_files/$i; done && + for i in $(test_seq 1 10); do touch 10_files/$i || return 1; done && + for i in $(test_seq 1 100); do touch 100_files/$i || return 1; done && + for i in $(test_seq 1 1000); do touch 1000_files/$i || return 1; done && + for i in $(test_seq 1 10000); do touch 10000_files/$i || return 1; done && git add 1_file 10_files 100_files 1000_files 10000_files && git commit -qm "Add files" && |