Skip to content

Commit

Permalink
Merge branch 'jn/maint-test-return'
Browse files Browse the repository at this point in the history
* 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_
  • Loading branch information
Junio C Hamano committed Aug 23, 2011
2 parents 6133e4d + 23ce5c3 commit 5245720
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions t/t3900-i18n-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -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
18 changes: 11 additions & 7 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5245720

Please sign in to comment.