From b559051394b533645b6d908348da8b97facf7458 Mon Sep 17 00:00:00 2001 From: brarcher Date: Tue, 17 Dec 2013 16:07:10 +0000 Subject: [PATCH] add support for descriptions in TAP logging The description on a TAP output line is as follows: [not] ok (number) - (file):(suite name):(test name): (message) git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@883 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- doc/check.texi | 8 ++++---- src/check_log.c | 2 +- tests/test_tap_output.sh | 34 ++++++++++++++++++++-------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/doc/check.texi b/doc/check.texi index d4a5f6e..c9c31eb 100644 --- a/doc/check.texi +++ b/doc/check.texi @@ -1542,10 +1542,10 @@ TAP output is enabled by a call to @code{srunner_set_tap()} before the tests are run. Here is an example of an TAP log: @example @verbatim -ok 1 -ok 2 -not ok 3 -ok 4 +ok 1 - mytests.c:test_suite_name:my_test_1: Passed +ok 2 - mytests.c:test_suite_name:my_test_2: Passed +not ok 3 - mytests.c:test_suite_name:my_test_3: Foo happened +ok 4 - mytests.c:test_suite_name:my_test_1: Passed 1..4 @end verbatim @end example diff --git a/src/check_log.c b/src/check_log.c index 6ff2b97..5c02f47 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -344,7 +344,7 @@ void tap_lfun (SRunner *sr, FILE *file, enum print_output printmode CK_ATTRIBUTE /* Print the test result to the tap file */ num_tests_run+=1; tr = obj; - fprintf(file, "%s %d\n", tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run); + fprintf(file, "%s %d - %s:%s:%s: %s\n", tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run, tr->file, tr->tcname, tr->tname, tr->msg); fflush(file); break; default: diff --git a/tests/test_tap_output.sh b/tests/test_tap_output.sh index 62b912f..b5fa2df 100755 --- a/tests/test_tap_output.sh +++ b/tests/test_tap_output.sh @@ -4,22 +4,28 @@ OUTPUT_FILE=test.tap . ./test_vars +if [ x"${SRCDIR}" != x"." ]; then + SRCDIR="${SRCDIR}/" +else + SRCDIR="" +fi + if [ $HAVE_FORK -eq 1 ]; then -expected_normal_tap="ok 1 -not ok 2 -not ok 3 -ok 4 +expected_normal_tap="ok 1 - ${SRCDIR}ex_tap_output.c:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_tap_output.c:Core:test_fail: Failure +not ok 3 - ${SRCDIR}ex_tap_output.c:Core:test_exit: Early exit with return value 1 +ok 4 - ${SRCDIR}ex_tap_output.c:Core:test_pass2: Passed 1..4" -expected_aborted_tap="ok 1 -not ok 2 -not ok 3 -not ok 4 -ok 5 +expected_aborted_tap="ok 1 - ${SRCDIR}ex_tap_output.c:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_tap_output.c:Core:test_fail: Failure +not ok 3 - ${SRCDIR}ex_tap_output.c:Core:test_exit: Early exit with return value 1 +not ok 4 - ${SRCDIR}ex_tap_output.c:Core:test_abort: Early exit with return value 1 +ok 5 - ${SRCDIR}ex_tap_output.c:Core:test_pass2: Passed 1..5" else -expected_normal_tap="ok 1 -not ok 2 -ok 3 +expected_normal_tap="ok 1 - ${SRCDIR}ex_tap_output.c:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_tap_output.c:Core:test_fail: Failure +ok 3 - ${SRCDIR}ex_tap_output.c:Core:test_pass2: Passed 1..3" # When fork() is unavailable, one of the tests # will invoke exit() which will terminate the @@ -27,8 +33,8 @@ ok 3 # results will be incomplete, but the required # test plan will be missing, signaling that # something bad happened. -expected_aborted_tap="ok 1 -not ok 2" +expected_aborted_tap="ok 1 - ${SRCDIR}ex_tap_output.c:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_tap_output.c:Core:test_fail: Failure" fi test_tap_output ( ) { -- 2.40.0