Merge branch 'jn/maint-test-return'

* jn/maint-test-return:
  t3900: do not reference numbered arguments from the test script
  test: cope better with use of return for errors
  test: simplify return value of test_run_
This commit is contained in:
Junio C Hamano 2011-08-23 15:35:26 -07:00
commit 52457205a2
2 changed files with 13 additions and 9 deletions

View File

@ -147,7 +147,7 @@ test_commit_autosquash_flags () {
git commit -a -m "intermediate commit" &&
test_tick &&
echo $H $flag >>F &&
git commit -a --$flag HEAD~1 $3 &&
git commit -a --$flag HEAD~1 &&
E=$(git cat-file commit '$H-$flag' |
sed -ne "s/^encoding //p") &&
test "z$E" = "z$H" &&
@ -160,6 +160,6 @@ test_commit_autosquash_flags () {
test_commit_autosquash_flags eucJP fixup
test_commit_autosquash_flags ISO-2022-JP squash '-m "squash message"'
test_commit_autosquash_flags ISO-2022-JP squash
test_done

View File

@ -444,20 +444,26 @@ test_debug () {
test "$debug" = "" || eval "$1"
}
test_eval_ () {
# This is a separate function because some tests use
# "return" to end a test_expect_success block early.
eval >&3 2>&4 "$*"
}
test_run_ () {
test_cleanup=:
expecting_failure=$2
eval >&3 2>&4 "$1"
test_eval_ "$1"
eval_ret=$?
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
then
eval >&3 2>&4 "$test_cleanup"
test_eval_ "$test_cleanup"
fi
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
echo ""
fi
return 0
return "$eval_ret"
}
test_skip () {
@ -502,8 +508,7 @@ test_expect_failure () {
if ! test_skip "$@"
then
say >&3 "checking known breakage: $2"
test_run_ "$2" expecting_failure
if [ "$?" = 0 -a "$eval_ret" = 0 ]
if test_run_ "$2" expecting_failure
then
test_known_broken_ok_ "$1"
else
@ -521,8 +526,7 @@ test_expect_success () {
if ! test_skip "$@"
then
say >&3 "expecting success: $2"
test_run_ "$2"
if [ "$?" = 0 -a "$eval_ret" = 0 ]
if test_run_ "$2"
then
test_ok_ "$1"
else