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);
} }
...@@ -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);
if (szTime) szTime[24] = '\0';
if (bJUnitXmlOutput == CU_TRUE) {
fprintf(f_pTestResultFile,
" </testsuite>\n</testsuites>\n");
}
else {
fprintf(f_pTestResultFile, fprintf(f_pTestResultFile,
" <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n" " <CUNIT_FOOTER> %s" CU_VERSION " - %s </CUNIT_FOOTER> \n"
"</CUNIT_TEST_RUN_REPORT>", "</CUNIT_TEST_RUN_REPORT>\n",
_("File Generated By CUnit v"), _("File Generated By CUnit v"),
(NULL != szTime) ? szTime : ""); (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
......
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