Commit 157821d2 authored by Nicolas Michon's avatar Nicolas Michon

Merge branch 'dev/parallel_tests' into 'master'

Add JUnit XML generation option

See merge request !1
parents 8f5e72c3 9aa1d439
Pipeline #886 passed with stage
in 0 seconds
......@@ -85,6 +85,8 @@ CU_EXPORT void CU_set_output_filename(const char* szFilenameRoot);
void CU_automated_enable_junit_xml(CU_BOOL bFlag);
void CU_automated_enable_partial_junit(CU_BOOL bFlag);
void CU_automated_package_name_set(const char *pName);
const char *CU_automated_package_name_get(void);
......
......@@ -78,6 +78,9 @@ static FILE* f_pTestResultFile = NULL; /**< FILE pointer th
static CU_BOOL f_bWriting_BCUNIT_RUN_SUITE = CU_FALSE; /**< Flag for keeping track of when a closing xml tag is required. */
static CU_BOOL bJUnitXmlOutput = CU_FALSE; /**< Flag for toggling the xml junit output or keeping the original. Off is the default */
static CU_BOOL bPartialSuiteJUnitReport = CU_FALSE; /** Flag for toggling englobing <testsuites> tags. Warning: allows imcomplete JUnit results file where only <testsuite></testsuite> will be present. This is to allow JUnit-xml output for a single suite */
static char _gPackageName[50] = "";
static time_t f_testStartTime = 0; /**< Start time of current running test suite. */
......@@ -235,9 +238,11 @@ static CU_ErrorCode initialize_result_file(const char* szFilename)
setvbuf(f_pTestResultFile, NULL, _IONBF, 0);
if (bJUnitXmlOutput == CU_TRUE) {
if (bPartialSuiteJUnitReport == CU_FALSE) {
fprintf(f_pTestResultFile,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<testsuites> \n");
}
} else {
fprintf(f_pTestResultFile,
"<?xml version=\"1.0\" ?> \n"
......@@ -643,7 +648,10 @@ static CU_ErrorCode uninitialize_result_file(void)
if (szTime) szTime[24] = '\0';
if (bJUnitXmlOutput == CU_TRUE) {
fprintf(f_pTestResultFile,
" </testsuite>\n</testsuites>\n");
" </testsuite>\n");
if (bPartialSuiteJUnitReport == CU_FALSE) {
fprintf(f_pTestResultFile, "</testsuites>\n");
}
}
else {
fprintf(f_pTestResultFile,
......@@ -790,6 +798,15 @@ void CU_automated_enable_junit_xml(CU_BOOL bFlag)
}
/** @} */
/*------------------------------------------------------------------------*/
/** Enable or Disable the englobing XML tags for <testsuites> in the JUnit file report
* This allows to create partial JUnit results file that will need to be merged.
*/
void CU_automated_enable_partial_junit(CU_BOOL bFlag)
{
bPartialSuiteJUnitReport = bFlag;
}
/*------------------------------------------------------------------------*/
/** Set tests suites package name
*/
......
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