Skip to content

Commit 5245720

Browse files
committed
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_
2 parents 6133e4d + 23ce5c3 commit 5245720

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

t/t3900-i18n-commit.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ test_commit_autosquash_flags () {
147147
git commit -a -m "intermediate commit" &&
148148
test_tick &&
149149
echo $H $flag >>F &&
150-
git commit -a --$flag HEAD~1 $3 &&
150+
git commit -a --$flag HEAD~1 &&
151151
E=$(git cat-file commit '$H-$flag' |
152152
sed -ne "s/^encoding //p") &&
153153
test "z$E" = "z$H" &&
@@ -160,6 +160,6 @@ test_commit_autosquash_flags () {
160160

161161
test_commit_autosquash_flags eucJP fixup
162162

163-
test_commit_autosquash_flags ISO-2022-JP squash '-m "squash message"'
163+
test_commit_autosquash_flags ISO-2022-JP squash
164164

165165
test_done

t/test-lib.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,26 @@ test_debug () {
444444
test "$debug" = "" || eval "$1"
445445
}
446446

447+
test_eval_ () {
448+
# This is a separate function because some tests use
449+
# "return" to end a test_expect_success block early.
450+
eval >&3 2>&4 "$*"
451+
}
452+
447453
test_run_ () {
448454
test_cleanup=:
449455
expecting_failure=$2
450-
eval >&3 2>&4 "$1"
456+
test_eval_ "$1"
451457
eval_ret=$?
452458

453459
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
454460
then
455-
eval >&3 2>&4 "$test_cleanup"
461+
test_eval_ "$test_cleanup"
456462
fi
457463
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
458464
echo ""
459465
fi
460-
return 0
466+
return "$eval_ret"
461467
}
462468

463469
test_skip () {
@@ -502,8 +508,7 @@ test_expect_failure () {
502508
if ! test_skip "$@"
503509
then
504510
say >&3 "checking known breakage: $2"
505-
test_run_ "$2" expecting_failure
506-
if [ "$?" = 0 -a "$eval_ret" = 0 ]
511+
if test_run_ "$2" expecting_failure
507512
then
508513
test_known_broken_ok_ "$1"
509514
else
@@ -521,8 +526,7 @@ test_expect_success () {
521526
if ! test_skip "$@"
522527
then
523528
say >&3 "expecting success: $2"
524-
test_run_ "$2"
525-
if [ "$?" = 0 -a "$eval_ret" = 0 ]
529+
if test_run_ "$2"
526530
then
527531
test_ok_ "$1"
528532
else

0 commit comments

Comments
 (0)