test-lib: Simplify test counting.

Since the test case counter was incremented very late, there were a few
users of the counter had to do their own incrementing. Now we increment it
early and simplify these users.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
Johannes Sixt 2009-02-05 21:20:56 +01:00
parent d5d9de1b10
commit 8586f98bd2
3 changed files with 5 additions and 11 deletions

View File

@ -101,8 +101,7 @@ do
'' | '#'*) continue ;; '' | '#'*) continue ;;
esac esac
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
cnt=`expr $test_count + 1` pfx=`printf "%04d" $test_count`
pfx=`printf "%04d" $cnt`
expect="$TEST_DIRECTORY/t4013/diff.$test" expect="$TEST_DIRECTORY/t4013/diff.$test"
actual="$pfx-diff.$test" actual="$pfx-diff.$test"

View File

@ -129,8 +129,7 @@ do
'' | '#'*) continue ;; '' | '#'*) continue ;;
esac esac
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'` test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
cnt=`expr $test_count + 1` pfx=`printf "%04d" $test_count`
pfx=`printf "%04d" $cnt`
expect_f="$TEST_DIRECTORY/t5515/fetch.$test" expect_f="$TEST_DIRECTORY/t5515/fetch.$test"
actual_f="$pfx-fetch.$test" actual_f="$pfx-fetch.$test"
expect_r="$TEST_DIRECTORY/t5515/refs.$test" expect_r="$TEST_DIRECTORY/t5515/refs.$test"

View File

@ -242,13 +242,11 @@ test_merge () {
# the text_expect_* functions instead. # the text_expect_* functions instead.
test_ok_ () { test_ok_ () {
test_count=$(($test_count + 1))
test_success=$(($test_success + 1)) test_success=$(($test_success + 1))
say_color "" " ok $test_count: $@" say_color "" " ok $test_count: $@"
} }
test_failure_ () { test_failure_ () {
test_count=$(($test_count + 1))
test_failure=$(($test_failure + 1)) test_failure=$(($test_failure + 1))
say_color error "FAIL $test_count: $1" say_color error "FAIL $test_count: $1"
shift shift
@ -257,13 +255,11 @@ test_failure_ () {
} }
test_known_broken_ok_ () { test_known_broken_ok_ () {
test_count=$(($test_count+1))
test_fixed=$(($test_fixed+1)) test_fixed=$(($test_fixed+1))
say_color "" " FIXED $test_count: $@" say_color "" " FIXED $test_count: $@"
} }
test_known_broken_failure_ () { test_known_broken_failure_ () {
test_count=$(($test_count+1))
test_broken=$(($test_broken+1)) test_broken=$(($test_broken+1))
say_color skip " still broken $test_count: $@" say_color skip " still broken $test_count: $@"
} }
@ -279,10 +275,11 @@ test_run_ () {
} }
test_skip () { test_skip () {
test_count=$(($test_count+1))
to_skip= to_skip=
for skp in $GIT_SKIP_TESTS for skp in $GIT_SKIP_TESTS
do do
case $this_test.$(($test_count+1)) in case $this_test.$test_count in
$skp) $skp)
to_skip=t to_skip=t
esac esac
@ -290,7 +287,6 @@ test_skip () {
case "$to_skip" in case "$to_skip" in
t) t)
say_color skip >&3 "skipping test: $@" say_color skip >&3 "skipping test: $@"
test_count=$(($test_count+1))
say_color skip "skip $test_count: $1" say_color skip "skip $test_count: $1"
: true : true
;; ;;
@ -368,7 +364,7 @@ test_external () {
then then
# Announce the script to reduce confusion about the # Announce the script to reduce confusion about the
# test output that follows. # test output that follows.
say_color "" " run $(($test_count+1)): $descr ($*)" say_color "" " run $test_count: $descr ($*)"
# Run command; redirect its stderr to &4 as in # Run command; redirect its stderr to &4 as in
# test_run_, but keep its stdout on our stdout even in # test_run_, but keep its stdout on our stdout even in
# non-verbose mode. # non-verbose mode.