t: fix some trivial cases of ignored exit codes in loops

These are all cases where we do a setup step of the form:

  for i in $foo; do
	  set_up $i || break
  done &&
  more_setup

would not notice a failure in set_up (because break always
returns a 0 exit code). These are just setup steps that we
do not expect to fail, but it does not hurt to be defensive.

Most can be fixed by converting the "break" to a "return 1"
(since we eval our tests inside a function for just this
purpose). A few of the loops are inside subshells, so we can
use just "exit 1" to break out of the subshell. And a few
can actually be made shorter by just unrolling the loop.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2015-03-25 01:29:52 -04:00 коммит произвёл Junio C Hamano
Родитель 76e057dba2
Коммит e6821d09e4
10 изменённых файлов: 24 добавлений и 28 удалений

Просмотреть файл

@ -55,13 +55,10 @@ test_expect_success 'git update-index --add to add various paths.' '
: >path9 && : >path9 &&
date >path10 && date >path10 &&
git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 && git update-index --add -- path0 path?/file? pathx/ju path7 path8 path9 path10 &&
for i in 1 2 git init submod1 &&
do git -C submod1 commit --allow-empty -m "empty 1" &&
git init submod$i && git init submod2 &&
( git -C submod2 commit --allow-empty -m "empty 2" &&
cd submod$i && git commit --allow-empty -m "empty $i"
) || break
done &&
git update-index --add submod[12] && git update-index --add submod[12] &&
( (
cd submod1 && cd submod1 &&

Просмотреть файл

@ -32,7 +32,7 @@ test_expect_success 'setup repo with criss-cross history' '
do do
echo $n > data/$n && echo $n > data/$n &&
n=$(($n+1)) || n=$(($n+1)) ||
break return 1
done && done &&
# check them in # check them in

Просмотреть файл

@ -19,7 +19,7 @@ test_expect_success 'setup' '
> file$i && > file$i &&
git add file$i && git add file$i &&
test_tick && test_tick &&
git commit -m branch$i || break git commit -m branch$i || return 1
done done
' '

Просмотреть файл

@ -139,7 +139,7 @@ test_expect_success setup '
( printf C; zs $n ) >file-c$n && ( printf C; zs $n ) >file-c$n &&
( echo D; zs $n ) >file-d$n && ( echo D; zs $n ) >file-d$n &&
expect_pattern $n || break expect_pattern $n || return 1
done >expect done >expect
' '

Просмотреть файл

@ -8,7 +8,7 @@ test_expect_success setup '
do do
blob=$(echo $i | git hash-object --stdin) && blob=$(echo $i | git hash-object --stdin) &&
eval "blob$i=$blob" && eval "blob$i=$blob" &&
eval "m$i=\"100644 \$blob$i $i\"" || break eval "m$i=\"100644 \$blob$i $i\"" || return 1
done && done &&
paths= && paths= &&
for b in o x for b in o x
@ -24,9 +24,9 @@ test_expect_success setup '
case "$b" in x) echo "$m1$p" ;; esac && case "$b" in x) echo "$m1$p" ;; esac &&
case "$o" in x) echo "$m2$p" ;; esac && case "$o" in x) echo "$m2$p" ;; esac &&
case "$t" in x) echo "$m3$p" ;; esac || case "$t" in x) echo "$m3$p" ;; esac ||
break return 1
done || break done
done || break done
done >ls-files-s.expect && done >ls-files-s.expect &&
git update-index --index-info <ls-files-s.expect && git update-index --index-info <ls-files-s.expect &&
git ls-files -s >ls-files-s.actual && git ls-files -s >ls-files-s.actual &&

Просмотреть файл

@ -20,7 +20,7 @@ test_expect_success setup '
echo $i >otherfile-$i && echo $i >otherfile-$i &&
git add otherfile-$i && git add otherfile-$i &&
test_tick && test_tick &&
git commit -a -m $i || break git commit -a -m $i || return 1
done && done &&
git format-patch --no-numbered initial && git format-patch --no-numbered initial &&
git checkout -b side initial && git checkout -b side initial &&

Просмотреть файл

@ -579,7 +579,7 @@ test_expect_success 'update with arguments' '
cd one && cd one &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git remote add manduca ../mirror && git remote add manduca ../mirror &&
git remote add megaloprepus ../mirror && git remote add megaloprepus ../mirror &&
@ -622,7 +622,7 @@ test_expect_success 'update default' '
cd one && cd one &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git config remote.drosophila.skipDefaultUpdate true && git config remote.drosophila.skipDefaultUpdate true &&
git remote update default && git remote update default &&
@ -642,7 +642,7 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
cd one && cd one &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git config remotes.default "$(printf "\t drosophila \n")" && git config remotes.default "$(printf "\t drosophila \n")" &&
git remote update default && git remote update default &&
@ -656,7 +656,7 @@ test_expect_success 'update (with remotes.default defined)' '
cd one && cd one &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git config remotes.default "drosophila" && git config remotes.default "drosophila" &&
git remote update && git remote update &&

Просмотреть файл

@ -120,7 +120,7 @@ test_expect_success 'git fetch --all (skipFetchAll)' '
(cd test4 && (cd test4 &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git remote add three ../three && git remote add three ../three &&
git config remote.three.skipFetchAll true && git config remote.three.skipFetchAll true &&
@ -144,7 +144,7 @@ test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
(cd test4 && (cd test4 &&
for b in $(git branch -r) for b in $(git branch -r)
do do
git branch -r -d $b || break git branch -r -d $b || exit 1
done && done &&
git fetch --multiple one two three && git fetch --multiple one two three &&
git branch -r > output && git branch -r > output &&

Просмотреть файл

@ -11,7 +11,7 @@ test_expect_success setup '
for f in text binary union for f in text binary union
do do
echo Initial >$f && git add $f || break echo Initial >$f && git add $f || return 1
done && done &&
test_tick && test_tick &&
git commit -m Initial && git commit -m Initial &&
@ -19,7 +19,7 @@ test_expect_success setup '
git branch side && git branch side &&
for f in text binary union for f in text binary union
do do
echo Master >>$f && git add $f || break echo Master >>$f && git add $f || return 1
done && done &&
test_tick && test_tick &&
git commit -m Master && git commit -m Master &&
@ -27,7 +27,7 @@ test_expect_success setup '
git checkout side && git checkout side &&
for f in text binary union for f in text binary union
do do
echo Side >>$f && git add $f || break echo Side >>$f && git add $f || return 1
done && done &&
test_tick && test_tick &&
git commit -m Side && git commit -m Side &&

Просмотреть файл

@ -12,10 +12,9 @@ advance () {
} }
test_expect_success setup ' test_expect_success setup '
for i in a b c; advance a &&
do advance b &&
advance $i || break advance c &&
done &&
git clone . test && git clone . test &&
( (
cd test && cd test &&