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>
Johannes Sixt committed
Feb 5, 2009 at 21:20 UTC
8586f98bd29bd4ad3d0e62a3be4a4d59ff8b27cd
3 files changed
+5
-11
t/t4013-diff-various.sh
+1
-2
@@ -101,8 +101,7 @@ do
101
'' | '#'*) continue ;;
102
esac
103
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
104
- cnt=`expr $test_count + 1`
105
- pfx=`printf "%04d" $cnt`
104
+ pfx=`printf "%04d" $test_count`
105
expect="$TEST_DIRECTORY/t4013/diff.$test"
106
actual="$pfx-diff.$test"
107
t/t5515-fetch-merge-logic.sh
+1
-2
@@ -129,8 +129,7 @@ do
129
'' | '#'*) continue ;;
130
esac
131
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
132
- cnt=`expr $test_count + 1`
133
- pfx=`printf "%04d" $cnt`
132
+ pfx=`printf "%04d" $test_count`
133
expect_f="$TEST_DIRECTORY/t5515/fetch.$test"
134
actual_f="$pfx-fetch.$test"
135
expect_r="$TEST_DIRECTORY/t5515/refs.$test"
t/test-lib.sh
+3
-7
@@ -242,13 +242,11 @@ test_merge () {
242
# the text_expect_* functions instead.
243
244
test_ok_ () {
245
- test_count=$(($test_count + 1))
245
test_success=$(($test_success + 1))
246
say_color "" " ok $test_count: $@"
247
}
248
249
test_failure_ () {
251
- test_count=$(($test_count + 1))
250
test_failure=$(($test_failure + 1))
251
say_color error "FAIL $test_count: $1"
252
shift
@@ -257,13 +255,11 @@ test_failure_ () {
255
}
256
257
test_known_broken_ok_ () {
260
- test_count=$(($test_count+1))
258
test_fixed=$(($test_fixed+1))
259
say_color "" " FIXED $test_count: $@"
260
}
261
262
test_known_broken_failure_ () {
266
- test_count=$(($test_count+1))
263
test_broken=$(($test_broken+1))
264
say_color skip " still broken $test_count: $@"
265
}
@@ -279,10 +275,11 @@ test_run_ () {
275
}
276
277
test_skip () {
278
+ test_count=$(($test_count+1))
279
to_skip=
280
for skp in $GIT_SKIP_TESTS
281
do
285
- case $this_test.$(($test_count+1)) in
282
+ case $this_test.$test_count in
283
$skp)
284
to_skip=t
285
esac
@@ -290,7 +287,6 @@ test_skip () {
287
case "$to_skip" in
288
t)
289
say_color skip >&3 "skipping test: $@"
293
- test_count=$(($test_count+1))
290
say_color skip "skip $test_count: $1"
291
: true
292
;;
@@ -368,7 +364,7 @@ test_external () {
364
then
365
# Announce the script to reduce confusion about the
366
# test output that follows.
371
- say_color "" " run $(($test_count+1)): $descr ($*)"
367
+ say_color "" " run $test_count: $descr ($*)"
368
# Run command; redirect its stderr to &4 as in
369
# test_run_, but keep its stdout on our stdout even in
370
# non-verbose mode.