Skip to content

Commit ffe1afe

Browse files
szedergitster
authored andcommitted
tests: show the test name and number at the start of verbose output
The verbose output of every test looks something like this: expecting success: echo content >file && git add file && git commit -m "add file" [master (root-commit) d1fbfbd] add file Author: A U Thor <[email protected]> 1 file changed, 1 insertion(+) create mode 100644 file ok 1 - commit works i.e. first an "expecting success" (or "checking known breakage") line followed by the commands to be executed, then the output of those comamnds, and finally an "ok"/"not ok" line containing the test name. Note that the test's name is only shown at the very end. With '-x' tracing enabled and/or in longer tests the verbose output might be several screenfulls long, making it harder than necessary to find where the output of the test with a given name starts (especially when the outputs to different file descriptors are racing, and the "expecting success"/command block arrives earlier than the "ok" line of the previous test). Print the test name at the start of the test's verbose output, i.e. at the end of the "expecting success" and "checking known breakage" lines, to make the start of a particular test a bit easier to recognize. Also print the test script and test case numbers, to help those poor souls who regularly have to scan through the combined verbose output of several test scripts. So the dummy test above would start like this: expecting success of 9999.1 'commit works': echo content >file && [...] Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 96f3ccc commit ffe1afe

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

t/t0000-basic.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,14 @@ test_expect_success C_LOCALE_OUTPUT 'test --verbose' '
285285
mv t1234-verbose/out t1234-verbose/out+ &&
286286
grep -v "^Initialized empty" t1234-verbose/out+ >t1234-verbose/out &&
287287
check_sub_test_lib_test t1234-verbose <<-\EOF
288-
> expecting success: true
288+
> expecting success of 1234.1 '\''passing test'\'': true
289289
> ok 1 - passing test
290290
> Z
291-
> expecting success: echo foo
291+
> expecting success of 1234.2 '\''test with output'\'': echo foo
292292
> foo
293293
> ok 2 - test with output
294294
> Z
295-
> expecting success: false
295+
> expecting success of 1234.3 '\''failing test'\'': false
296296
> not ok 3 - failing test
297297
> # false
298298
> Z
@@ -313,7 +313,7 @@ test_expect_success 'test --verbose-only' '
313313
check_sub_test_lib_test t2345-verbose-only-2 <<-\EOF
314314
> ok 1 - passing test
315315
> Z
316-
> expecting success: echo foo
316+
> expecting success of 2345.2 '\''test with output'\'': echo foo
317317
> foo
318318
> ok 2 - test with output
319319
> Z

t/test-lib-functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ test_expect_failure () {
437437
export test_prereq
438438
if ! test_skip "$@"
439439
then
440-
say >&3 "checking known breakage: $2"
440+
say >&3 "checking known breakage of $TEST_NUMBER.$test_count '$1': $2"
441441
if test_run_ "$2" expecting_failure
442442
then
443443
test_known_broken_ok_ "$1"
@@ -457,7 +457,7 @@ test_expect_success () {
457457
export test_prereq
458458
if ! test_skip "$@"
459459
then
460-
say >&3 "expecting success: $2"
460+
say >&3 "expecting success of $TEST_NUMBER.$test_count '$1': $2"
461461
if test_run_ "$2"
462462
then
463463
test_ok_ "$1"

t/test-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ fi
212212

213213
TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}"
214214
TEST_NAME="$(basename "$0" .sh)"
215+
TEST_NUMBER="${TEST_NAME%%-*}"
216+
TEST_NUMBER="${TEST_NUMBER#t}"
215217
TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results"
216218
TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX"
217219
TRASH_DIRECTORY="trash directory.$TEST_NAME$TEST_STRESS_JOB_SFX"

0 commit comments

Comments
 (0)