Automated.c: add test duration in XML report and fix JUnit generation and bump v3.0-1

parent 19f5ddb3
...@@ -26,8 +26,8 @@ project(CUNIT C) ...@@ -26,8 +26,8 @@ project(CUNIT C)
set(PACKAGE "CUnit") set(PACKAGE "CUnit")
set(PACKAGE_NAME "${PACKAGE}") set(PACKAGE_NAME "${PACKAGE}")
set(VERSION "2.1") set(VERSION "3.0")
set(RELEASE "2") set(RELEASE "1")
set(PACKAGE_VERSION "${VERSION}-${RELEASE}") set(PACKAGE_VERSION "${VERSION}-${RELEASE}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "") set(PACKAGE_BUGREPORT "")
......
...@@ -80,6 +80,8 @@ static CU_BOOL f_bWriting_CUNIT_RUN_SUITE = CU_FALSE; /**< Flag for keepin ...@@ -80,6 +80,8 @@ static CU_BOOL f_bWriting_CUNIT_RUN_SUITE = CU_FALSE; /**< Flag for keepin
static CU_BOOL bJUnitXmlOutput = CU_FALSE; /**< Flag for toggling the xml junit output or keeping the original. Off is the default */ static CU_BOOL bJUnitXmlOutput = CU_FALSE; /**< Flag for toggling the xml junit output or keeping the original. Off is the default */
static char _gPackageName[50] = ""; static char _gPackageName[50] = "";
static time_t f_testStartTime = 0; /**< Start time of current running test suite. */
/*================================================================= /*=================================================================
* Static function forward declarations * Static function forward declarations
*=================================================================*/ *=================================================================*/
...@@ -265,6 +267,8 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_ ...@@ -265,6 +267,8 @@ static void automated_test_start_message_handler(const CU_pTest pTest, const CU_
char *szTempName = NULL; char *szTempName = NULL;
size_t szTempName_len = 0; size_t szTempName_len = 0;
f_testStartTime = time(NULL);
if( test_start_handler ){ if( test_start_handler ){
(*test_start_handler)(pTest, pSuite); (*test_start_handler)(pTest, pSuite);
} }
...@@ -333,7 +337,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -333,7 +337,7 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
size_t cur_len = 0; size_t cur_len = 0;
CU_pFailureRecord pTempFailure = pFailure; CU_pFailureRecord pTempFailure = pFailure;
const char *pPackageName = CU_automated_package_name_get(); const char *pPackageName = CU_automated_package_name_get();
if( test_complete_handler ){ if( test_complete_handler ){
(*test_complete_handler)(pTest, pSuite, pFailure); (*test_complete_handler)(pTest, pSuite, pFailure);
} }
...@@ -354,16 +358,18 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -354,16 +358,18 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
assert((NULL != pTempFailure->pTest) && (pTempFailure->pTest == pTest)); assert((NULL != pTempFailure->pTest) && (pTempFailure->pTest == pTest));
if (NULL != pTempFailure->strCondition) { if (NULL != pTempFailure->strCondition) {
szTemp = (char *)CU_MALLOC(CU_translated_strlen(pTempFailure->strCondition));
CU_translate_special_characters(pTempFailure->strCondition, szTemp, sizeof(szTemp)); CU_translate_special_characters(pTempFailure->strCondition, szTemp, sizeof(szTemp));
} }
else { else {
szTemp[0] = '\0'; szTemp[0] = '\0';
} }
fprintf(f_pTestResultFile, " <testcase classname=\"%s.%s\" name=\"%s\" time=\"0\">\n", fprintf(f_pTestResultFile, " <testcase classname=\"%s.%s\" name=\"%s\" time=\"%ld\">\n",
pPackageName, pPackageName,
pSuite->pName, pSuite->pName,
(NULL != pTest->pName) ? pTest->pName : ""); (NULL != pTest->pName) ? pTest->pName : "",
(long)(time(NULL) - f_testStartTime));
fprintf(f_pTestResultFile, " <failure message=\"%s\" type=\"Failure\">\n", szTemp); fprintf(f_pTestResultFile, " <failure message=\"%s\" type=\"Failure\">\n", szTemp);
} /* if */ } /* if */
} }
...@@ -425,10 +431,11 @@ static void automated_test_complete_message_handler(const CU_pTest pTest, ...@@ -425,10 +431,11 @@ static void automated_test_complete_message_handler(const CU_pTest pTest,
} }
else { else {
if (bJUnitXmlOutput == CU_TRUE) { if (bJUnitXmlOutput == CU_TRUE) {
fprintf(f_pTestResultFile, " <testcase classname=\"%s.%s\" name=\"%s\" time=\"0\"/>\n", fprintf(f_pTestResultFile, " <testcase classname=\"%s.%s\" name=\"%s\" time=\"%ld\"/>\n",
pPackageName, pPackageName,
pSuite->pName, pSuite->pName,
(NULL != pTest->pName) ? pTest->pName : ""); (NULL != pTest->pName) ? pTest->pName : "",
(long)(time(NULL) - f_testStartTime));
} else { } else {
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_RUN_TEST_RECORD> \n" " <CUNIT_RUN_TEST_RECORD> \n"
...@@ -637,11 +644,18 @@ static CU_ErrorCode uninitialize_result_file(void) ...@@ -637,11 +644,18 @@ static CU_ErrorCode uninitialize_result_file(void)
time(&tTime); time(&tTime);
szTime = ctime(&tTime); szTime = ctime(&tTime);
fprintf(f_pTestResultFile, if (szTime) szTime[24] = '\0';
" <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n" if (bJUnitXmlOutput == CU_TRUE) {
"</CUNIT_TEST_RUN_REPORT>", fprintf(f_pTestResultFile,
_("File Generated By CUnit v"), " </testsuite>\n</testsuites>\n");
(NULL != szTime) ? szTime : ""); }
else {
fprintf(f_pTestResultFile,
" <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_RUN_REPORT>\n",
_("File Generated By CUnit v"),
(NULL != szTime) ? szTime : "");
}
if (0 != fclose(f_pTestResultFile)) { if (0 != fclose(f_pTestResultFile)) {
CU_set_error(CUE_FCLOSE_FAILED); CU_set_error(CUE_FCLOSE_FAILED);
...@@ -754,9 +768,10 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c ...@@ -754,9 +768,10 @@ static CU_ErrorCode automated_list_all_tests(CU_pTestRegistry pRegistry, const c
time(&tTime); time(&tTime);
szTime = ctime(&tTime); szTime = ctime(&tTime);
if (szTime) szTime[24] = '\0';
fprintf(pTestListFile, fprintf(pTestListFile,
" <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n" " <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_LIST_REPORT>", "</CUNIT_TEST_LIST_REPORT>\n",
_("File Generated By CUnit v"), _("File Generated By CUnit v"),
(NULL != szTime) ? szTime : ""); (NULL != szTime) ? szTime : "");
......
dnl Applied patch to handle AC_ARG_ENABLE targets (Patch 1250604) - Provided by Andrew Kephart <andrew.kephart@alereon.com dnl Applied patch to handle AC_ARG_ENABLE targets (Patch 1250604) - Provided by Andrew Kephart <andrew.kephart@alereon.com
AC_INIT(CUnit, 2.1-2) AC_INIT(CUnit, 3.0-1)
AM_INIT_AUTOMAKE(CUnit, 2.1-2) AM_INIT_AUTOMAKE(CUnit, 3.0-1)
dnl Package version information dnl Package version information
PACKAGE=CUnit PACKAGE=CUnit
VERSION_MAJOR=2 VERSION_MAJOR=3
VERSION_MINOR=1 VERSION_MINOR=0
VERSION=${VERSION_MAJOR}.${VERSION_MINOR} VERSION=${VERSION_MAJOR}.${VERSION_MINOR}
RELEASE=2 RELEASE=1
dnl Shared library version information dnl Shared library version information
dnl dnl
...@@ -239,28 +239,28 @@ dnl Configure Jamrules for user environment ...@@ -239,28 +239,28 @@ dnl Configure Jamrules for user environment
AC_CONFIG_FILES([Jamrules:Jamrules.in]) AC_CONFIG_FILES([Jamrules:Jamrules.in])
dnl Configure Makefile set. dnl Configure Makefile set.
AC_CONFIG_FILES( Makefile AC_CONFIG_FILES( Makefile
CUnit.spec CUnit.spec
cunit.pc cunit.pc
CUnit/Makefile CUnit/Makefile
CUnit/Headers/Makefile CUnit/Headers/Makefile
CUnit/Headers/CUnit.h CUnit/Headers/CUnit.h
CUnit/Sources/Makefile CUnit/Sources/Makefile
CUnit/Sources/Framework/Makefile CUnit/Sources/Framework/Makefile
CUnit/Sources/Automated/Makefile CUnit/Sources/Automated/Makefile
CUnit/Sources/Basic/Makefile CUnit/Sources/Basic/Makefile
CUnit/Sources/Console/Makefile CUnit/Sources/Console/Makefile
CUnit/Sources/Curses/Makefile CUnit/Sources/Curses/Makefile
CUnit/Sources/Test/Makefile CUnit/Sources/Test/Makefile
doc/Makefile doc/Makefile
doc/headers/Makefile doc/headers/Makefile
Examples/Makefile Examples/Makefile
Examples/AutomatedTest/Makefile Examples/AutomatedTest/Makefile
Examples/BasicTest/Makefile Examples/BasicTest/Makefile
Examples/ConsoleTest/Makefile Examples/ConsoleTest/Makefile
Examples/CursesTest/Makefile Examples/CursesTest/Makefile
Man/Makefile Man/Makefile
Man/man3/Makefile Man/man3/Makefile
Share/Makefile ) Share/Makefile )
AC_OUTPUT AC_OUTPUT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment