t: simplify loop exit-code status variables
Since shell loops may drop the exit code of failed commands inside the loop, some tests try to keep track of the status by setting a variable. This can end up cumbersome and hard to read; it is much simpler to just exit directly from the loop using "return 1" (since each case is either in a helper function or inside a test snippet). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e6821d09e4
commit
c6587bddc4
@ -18,22 +18,16 @@ test_expect_success setup '
|
|||||||
|
|
||||||
echo file >expected &&
|
echo file >expected &&
|
||||||
mkdir sub &&
|
mkdir sub &&
|
||||||
bad= &&
|
|
||||||
for n in 0 1 2 3 4 5
|
for n in 0 1 2 3 4 5
|
||||||
do
|
do
|
||||||
for m in 0 1 2 3 4 5 6 7 8 9
|
for m in 0 1 2 3 4 5 6 7 8 9
|
||||||
do
|
do
|
||||||
num=00$n$m &&
|
num=00$n$m &&
|
||||||
>sub/file-$num &&
|
>sub/file-$num &&
|
||||||
echo file-$num >>expected || {
|
echo file-$num >>expected ||
|
||||||
bad=t
|
return 1
|
||||||
break
|
done
|
||||||
}
|
done &&
|
||||||
done && test -z "$bad" || {
|
|
||||||
bad=t
|
|
||||||
break
|
|
||||||
}
|
|
||||||
done && test -z "$bad" &&
|
|
||||||
git add . &&
|
git add . &&
|
||||||
git commit -m "add a bunch of files" &&
|
git commit -m "add a bunch of files" &&
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ test_description='i18n settings and format-patch | am pipe'
|
|||||||
|
|
||||||
check_encoding () {
|
check_encoding () {
|
||||||
# Make sure characters are not corrupted
|
# Make sure characters are not corrupted
|
||||||
cnt="$1" header="$2" i=1 j=0 bad=0
|
cnt="$1" header="$2" i=1 j=0
|
||||||
while test "$i" -le $cnt
|
while test "$i" -le $cnt
|
||||||
do
|
do
|
||||||
git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
|
git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
|
||||||
@ -20,14 +20,10 @@ check_encoding () {
|
|||||||
grep "^encoding ISO8859-1" ;;
|
grep "^encoding ISO8859-1" ;;
|
||||||
*)
|
*)
|
||||||
grep "^encoding ISO8859-1"; test "$?" != 0 ;;
|
grep "^encoding ISO8859-1"; test "$?" != 0 ;;
|
||||||
esac || {
|
esac || return 1
|
||||||
bad=1
|
|
||||||
break
|
|
||||||
}
|
|
||||||
j=$i
|
j=$i
|
||||||
i=$(($i+1))
|
i=$(($i+1))
|
||||||
done
|
done
|
||||||
(exit $bad)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
Loading…
Reference in New Issue
Block a user