mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
tests: apply modern idiom for exiting loop upon failure
Rather than maintaining a flag indicating a failure within a loop and aborting the test when the loop ends if the flag is set, modern practice is to signal the failure immediately by exiting the loop early via `return 1` (or `exit 1` if inside a subshell). Simplify these loops by following the modern idiom. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
77b1d9f355
commit
03949e33f5
|
@ -51,27 +51,21 @@ EOF
|
|||
test_expect_success 'add a large file or two' '
|
||||
git add large1 huge large2 &&
|
||||
# make sure we got a single packfile and no loose objects
|
||||
bad= count=0 idx= &&
|
||||
count=0 idx= &&
|
||||
for p in .git/objects/pack/pack-*.pack
|
||||
do
|
||||
count=$(( $count + 1 )) &&
|
||||
if test_path_is_file "$p" &&
|
||||
idx=${p%.pack}.idx && test_path_is_file "$idx"
|
||||
then
|
||||
continue
|
||||
fi
|
||||
bad=t
|
||||
test_path_is_file "$p" &&
|
||||
idx=${p%.pack}.idx &&
|
||||
test_path_is_file "$idx" || return 1
|
||||
done &&
|
||||
test -z "$bad" &&
|
||||
test $count = 1 &&
|
||||
cnt=$(git show-index <"$idx" | wc -l) &&
|
||||
test $cnt = 2 &&
|
||||
for l in .git/objects/$OIDPATH_REGEX
|
||||
do
|
||||
test_path_is_file "$l" || continue
|
||||
bad=t
|
||||
test_path_is_missing "$l" || return 1
|
||||
done &&
|
||||
test -z "$bad" &&
|
||||
|
||||
# attempt to add another copy of the same
|
||||
git add large3 &&
|
||||
|
@ -79,14 +73,10 @@ test_expect_success 'add a large file or two' '
|
|||
for p in .git/objects/pack/pack-*.pack
|
||||
do
|
||||
count=$(( $count + 1 )) &&
|
||||
if test_path_is_file "$p" &&
|
||||
idx=${p%.pack}.idx && test_path_is_file "$idx"
|
||||
then
|
||||
continue
|
||||
fi
|
||||
bad=t
|
||||
test_path_is_file "$p" &&
|
||||
idx=${p%.pack}.idx &&
|
||||
test_path_is_file "$idx" || return 1
|
||||
done &&
|
||||
test -z "$bad" &&
|
||||
test $count = 1
|
||||
'
|
||||
|
||||
|
|
|
@ -1332,7 +1332,6 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
|
|||
(
|
||||
cd test &&
|
||||
git tag -a -m "Some tag" some-tag main &&
|
||||
exit_with=true &&
|
||||
for type in commit tag tree blob
|
||||
do
|
||||
if test "$type" = "blob"
|
||||
|
@ -1348,9 +1347,8 @@ test_expect_success 'unqualified <dst> refspec DWIM and advice' '
|
|||
push origin $oid:dst 2>err &&
|
||||
test_i18ngrep "error: The destination you" err &&
|
||||
test_i18ngrep ! "hint: Did you mean" err ||
|
||||
exit_with=false
|
||||
done &&
|
||||
$exit_with
|
||||
exit 1
|
||||
done
|
||||
)
|
||||
'
|
||||
|
||||
|
|
|
@ -350,10 +350,9 @@ test_expect_success 'cvs update (subdirectories)' \
|
|||
test_cmp "$dir/$filename" "../$dir/$filename"; then
|
||||
:
|
||||
else
|
||||
echo >failure
|
||||
exit 1
|
||||
fi
|
||||
done) &&
|
||||
test ! -f failure'
|
||||
done)'
|
||||
|
||||
cd "$WORKDIR"
|
||||
test_expect_success 'cvs update (delete file)' \
|
||||
|
|
Loading…
Reference in a new issue