From 60af3f83ac4bda74c8770ee8219e7d8ee44ab89c Mon Sep 17 00:00:00 2001 From: hugo303 Date: Wed, 18 Aug 2004 12:52:09 +0000 Subject: [PATCH] Fixed distcheck problem git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@186 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- check/ChangeLog | 9 +++++++++ check/src/check_print.c | 22 +++++++++++++++++++++- check/tests/test_xml_output.sh | 4 ++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/check/ChangeLog b/check/ChangeLog index 3427ea2..44f409d 100644 --- a/check/ChangeLog +++ b/check/ChangeLog @@ -1,3 +1,12 @@ +2004-08-18 hugo303 + + * src/check.c, src/check.h.in, src/check_impl.h, src/check_log.c, + src/check_log.h, src/check_print.c, src/check_print.h, + src/check_run.c, tests/Makefile.am, tests/check_check_log.c, + tests/ex_xml_output.c, tests/test_xml_output.sh: + Added support for XML output of the test results, courtesy of + Frederic Peters. + 2004-08-18 hugo303 * src/check_run.c, tests/check_check_fixture.c: Fixed setup bug diff --git a/check/src/check_print.c b/check/src/check_print.c index c0f0db1..1c50e3f 100644 --- a/check/src/check_print.c +++ b/check/src/check_print.c @@ -95,6 +95,9 @@ void tr_fprint (FILE *file, TestResult *tr, enum print_output print_mode) void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode) { char result[10]; + char *path_name; + char *file_name; + char *slash; switch (tr->rtype) { case CK_PASS: @@ -107,12 +110,29 @@ void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode) strcpy(result, "error"); break; } + + slash = strrchr(tr->file, '/'); + if (slash == NULL) { + path_name = (char*)"."; + file_name = tr->file; + } else { + path_name = strdup(tr->file); + path_name[slash - tr->file] = 0; /* Terminate the temporary string. */ + file_name = slash + 1; + } + + fprintf(file, " \n", result); - fprintf(file, " %s:%d\n", tr->file, tr->line); + fprintf(file, " %s\n", path_name); + fprintf(file, " %s:%d\n", file_name, tr->line); fprintf(file, " %s\n", tr->tname); fprintf(file, " %s\n", tr->tcname); fprintf(file, " %s\n", tr->msg); fprintf(file, " \n"); + + if (slash != NULL) { + free(path_name); + } } enum print_output get_env_printmode (void) diff --git a/check/tests/test_xml_output.sh b/check/tests/test_xml_output.sh index 104475d..e1fce7f 100755 --- a/check/tests/test_xml_output.sh +++ b/check/tests/test_xml_output.sh @@ -41,9 +41,9 @@ expected=" " ./ex_xml_output > /dev/null -actual=`cat test.log.xml | grep -v duration | grep -v datetime` +actual=`cat test.log.xml | grep -v \ | grep -v \ | grep -v \` if [ x"${expected}" != x"${actual}" ]; then - echo "Problem with ex_log_output ${3}"; + echo "Problem with ex_xml_output ${3}"; echo "Expected:"; echo "${expected}"; echo "Got:"; -- 2.40.0