Commit f8ef72e8 authored by jds2's avatar jds2

- modified dtd and xsl files to support inactive suites/tests.

- instrumented entire framework/interfaces for gettext
    (not activated yet, just instrumented source).


git-svn-id: http://svn.code.sf.net/p/cunit/code/trunk@101 f00e6729-6848-4c17-8bfb-678c97c00071
parent 58a586f1
......@@ -19,7 +19,7 @@
*/
/*
* Contains Interface for console Run tests.
* Contains Interface for curses Run tests.
*
* Aug 2001 Initial implementation. (AK)
*
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004,2005,2006 Anil Kumar, Jerry St.Clair
* Copyright (C) 2001 Anil Kumar
* Copyright (C) 2004-2006 Anil Kumar, Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -19,7 +19,7 @@
*/
/*
* Contains ASSERT Macro definitions.
* ASSERT Macro definitions and general CUnit configuration definitions.
*
* 09/Aug/2001 ASSERT definitions. (AK)
*
......@@ -83,7 +83,15 @@
#define CU_UNREFERENCED_PARAMETER(x) (void)x
#endif
#ifdef WIN32
#ifndef CU_MAX
# define CU_MAX(a,b) (((a) >= (b)) ? (a) : (b))
#endif
#ifndef CU_MIN
# define CU_MIN(a,b) (((a) >= (b)) ? (b) : (a))
#endif
#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_)
# ifdef CU_DLL
# ifdef CU_BUILD_DLL
# define CU_EXPORT __declspec(dllexport)
......@@ -93,9 +101,13 @@
# else
# define CU_EXPORT
# endif
# ifdef _MSC_VER
# define snprintf _snprintf
# define itoa _itoa
# endif
#else
# define CU_EXPORT
#endif
#endif /* WIN32 */
#include "CUError.h"
#include "TestDB.h" /* not needed here - included for user convenience */
......
/*
* CUnit - A Unit testing framework library for C.
* Copyright (C) 2006 Jerry St.Clair
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Internationalization support
*
* 05-May-2006 Initial implementation. (JDS)
*/
/** @file
* Internal CUnit header supporting internationalization of
* CUnit framework & interfaces.
*/
/** @addtogroup Framework
* @{
*/
#ifndef CUNIT_CUNIT_INTL_H_SEEN
#define CUNIT_CUNIT_INTL_H_SEEN
/* activate these when source preparation is complete
#include <libintl.h>
#ifndef _
# define _(String) gettext (String)
#endif
#ifndef gettext_noop
# define gettext_noop(String) String
#endif
#ifndef N_
# define N_(String) gettext_noop (String)
#endif
*/
/* deactivate these when source preparation is complete */
#undef _
#define _(String) (String)
#undef N_
#define N_(String) String
#undef textdomain
#define textdomain(Domain)
#undef bindtextdomain
#define bindtextdomain(Package, Directory)
#endif /* CUNIT_CUNIT_INTL_H_SEEN */
/** @} */
......@@ -281,7 +281,7 @@ CU_pSuite CU_add_suite(const char *strName,
* initialized before calling this function (checked by assertion).
* pInit and pClean may be NULL, in which case no corresponding
* initialization of cleanup function will be called when the suite
* is run.<br /><br />
* is run. strName may be empty ("") but may not be NULL.<br /><br />
*
* The return value is a pointer to the newly-created suite, or
* NULL if there was a problem with the suite creation or addition.
......
......@@ -38,6 +38,9 @@
* 23-Apr-2006 Moved doxygen comments into header.
* Added type marker to CU_FailureRecord.
* Added support for tracking inactive suites/tests. (JDS)
*
* 08-May-2006 Moved CU_print_run_results() functionality from
* console/basic test complete handler. (JDS)
*/
/** @file
......@@ -315,6 +318,20 @@ CU_EXPORT CU_pRunSummary CU_get_run_summary(void);
* initiates a run using CU_run_all_tests(), CU_run_suite(), or CU_run_test().
*/
CU_EXPORT void CU_print_run_results(FILE *file);
/**<
* Prints a summary of the current run to file.
* The run summary presents data for the suites, tests, and assertions
* encountered during the run. The data presented include the number
* of registered, run, passed, failed, and inactive entities for each.
* This function can be called at any time, although the test registry
* must have been initialized and file may not be NULL (both checked by
* assertion).
*
* @param file Pointer to stream to receive the printed summary.
*/
/*--------------------------------------------------------------------
* Functions for internal & testing use.
*--------------------------------------------------------------------*/
......
......@@ -31,7 +31,7 @@
*
* 5-Sep-2004 Added internal test interface. (JDS)
*
* 17-Apr-2006 Added CU_translated_strlen().
* 17-Apr-2006 Added CU_translated_strlen() and CU_number_width().
* Removed CUNIT_MAX_STRING_LENGTH - dangerous since not enforced.
* Fixed off-by-1 error in CU_translate_special_characters(),
* modifying implementation & results in some cases. User can
......@@ -74,7 +74,7 @@ CU_EXPORT size_t CU_translate_special_characters(const char *szSrc, char *szDest
* in an unspecified manner. It is the caller's responsibility to make
* sure there is sufficient room in szDest to hold the converted string.
* CU_translated_strlen() may be used to calculate the length of buffer
* required (remembering to add 1 for the terminating \0).
* required (remember to add 1 for the terminating \0).
*
* @param szSrc Source string to convert (non-NULL).
* @param szDest Location to hold the converted string (non-NULL).
......@@ -107,22 +107,28 @@ CU_EXPORT int CU_compare_strings(const char *szSrc, const char *szDest);
CU_EXPORT void CU_trim_left(char *szString);
/**<
* Trim leading whitespace from the specified string.
* Trims leading whitespace from the specified string.
* @param szString The string to trim.
*/
CU_EXPORT void CU_trim_right(char *szString);
/**<
* Trim trailing whitespace from the specified string.
* Trims trailing whitespace from the specified string.
* @param szString The string to trim.
*/
CU_EXPORT void CU_trim(char *szString);
/**<
* Trim leading and trailing whitespace from the specified string.
* Trims leading and trailing whitespace from the specified string.
* @param szString The string to trim.
*/
CU_EXPORT size_t CU_number_width(int number);
/**<
* Calulates the number of places required to display
* number in decimal.
*/
#ifdef CUNIT_BUILD_TESTS
void test_cunit_Util(void);
#endif
......
This diff is collapsed.
......@@ -25,6 +25,8 @@
* 8-Jan-2005 Fixed reporting bug (bug report cunit-Bugs-1093861). (JDS)
*
* 30-Apr-2005 Added notification of suite cleanup failure. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/
/** @file
......@@ -45,6 +47,7 @@
#include "Util.h"
#include "TestRun.h"
#include "Basic.h"
#include "CUnit_intl.h"
/*=================================================================
* Global/Static Definitions
......@@ -77,7 +80,7 @@ CU_ErrorCode CU_basic_run_tests(void)
if (NULL == CU_get_registry()) {
if (CU_BRM_SILENT != f_run_mode)
fprintf(stderr, "\n\nFATAL ERROR - Test registry is not initialized.\n");
fprintf(stderr, "\n\n%s\n", _("FATAL ERROR - Test registry is not initialized."));
error = CUE_NOREGISTRY;
}
else if (CUE_SUCCESS == (error = basic_initialize()))
......@@ -156,8 +159,10 @@ static CU_ErrorCode basic_initialize(void)
CU_set_error(CUE_SUCCESS);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout, "\n\n CUnit - A Unit testing framework for C - Version " CU_VERSION
"\n http://cunit.sourceforge.net/\n\n");
fprintf(stdout, "\n\n %s" CU_VERSION
"\n %s\n\n",
_("CUnit - A unit testing framework for C - Version "),
_("http://cunit.sourceforge.net/"));
CU_set_test_start_handler(basic_test_start_message_handler);
CU_set_test_complete_handler(basic_test_complete_message_handler);
......@@ -230,13 +235,15 @@ static void basic_test_start_message_handler(const CU_pTest pTest, const CU_pSui
assert(NULL != pTest);
if (CU_BRM_VERBOSE == f_run_mode) {
assert(NULL != pTest->pName);
if ((NULL == f_pRunningSuite) || (f_pRunningSuite != pSuite)) {
fprintf(stdout, "\nSuite: %s", (NULL != pSuite->pName) ? pSuite->pName : "");
fprintf(stdout, "\n Test: %s ... ", (NULL != pTest->pName) ? pTest->pName : "");
assert(NULL != pSuite->pName);
fprintf(stdout, "\n%s: %s", _("Suite"), pSuite->pName);
fprintf(stdout, "\n %s: %s ...", _("Test"), pTest->pName);
f_pRunningSuite = pSuite;
}
else {
fprintf(stdout, "\n Test: %s ... ", (NULL != pTest->pName) ? pTest->pName : "");
fprintf(stdout, "\n %s: %s ...", _("Test"), pTest->pName);
}
}
}
......@@ -259,18 +266,18 @@ static void basic_test_complete_message_handler(const CU_pTest pTest,
if (NULL == pFailure) {
if (CU_BRM_VERBOSE == f_run_mode) {
fprintf(stdout, "passed");
fprintf(stdout, _("passed"));
}
}
else {
switch (f_run_mode) {
case CU_BRM_VERBOSE:
fprintf(stdout, "FAILED");
fprintf(stdout, _("FAILED"));
break;
case CU_BRM_NORMAL:
fprintf(stdout, "\nSuite %s, Test %s had failures:",
(NULL != pSuite->pName) ? pSuite->pName : "",
(NULL != pTest->pName) ? pTest->pName : "");
assert(NULL != pSuite->pName);
assert(NULL != pTest->pName);
fprintf(stdout, _("\nSuite %s, Test %s had failures:"), pSuite->pName, pTest->pName);
break;
default: /* gcc wants all enums covered. ok. */
break;
......@@ -292,32 +299,8 @@ static void basic_test_complete_message_handler(const CU_pTest pTest,
*/
static void basic_all_tests_complete_message_handler(const CU_pFailureRecord pFailure)
{
CU_pRunSummary pRunSummary = CU_get_run_summary();
CU_pTestRegistry pRegistry = CU_get_registry();
CU_UNREFERENCED_PARAMETER(pFailure); /* not used in basic interface */
assert(NULL != pRunSummary);
assert(NULL != pRegistry);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout,"\n\n--Run Summary: Type Total Ran Passed Failed Inactive"
"\n suites %8u%8u n/a%8u%8u"
"\n tests %8u%8u%8u%8u%8u"
"\n asserts%8u%8u%8u%8u n/a\n",
pRegistry->uiNumberOfSuites,
pRunSummary->nSuitesRun,
pRunSummary->nSuitesFailed,
pRunSummary->nSuitesInactive,
pRegistry->uiNumberOfTests,
pRunSummary->nTestsRun,
pRunSummary->nTestsRun - pRunSummary->nTestsFailed,
pRunSummary->nTestsFailed,
pRunSummary->nTestsInactive,
pRunSummary->nAsserts,
pRunSummary->nAsserts,
pRunSummary->nAsserts - pRunSummary->nAssertsFailed,
pRunSummary->nAssertsFailed);
CU_print_run_results(stdout);
}
/*------------------------------------------------------------------------*/
......@@ -327,11 +310,10 @@ static void basic_all_tests_complete_message_handler(const CU_pFailureRecord pFa
static void basic_suite_init_failure_message_handler(const CU_pSuite pSuite)
{
assert(NULL != pSuite);
assert(NULL != pSuite->pName);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout,
"\nWARNING - Suite initialization failed for %s.",
(NULL != pSuite->pName) ? pSuite->pName : "");
fprintf(stdout, _("\nWARNING - Suite initialization failed for '%s'."), pSuite->pName);
}
/*------------------------------------------------------------------------*/
......@@ -341,11 +323,10 @@ static void basic_suite_init_failure_message_handler(const CU_pSuite pSuite)
static void basic_suite_cleanup_failure_message_handler(const CU_pSuite pSuite)
{
assert(NULL != pSuite);
assert(NULL != pSuite->pName);
if (CU_BRM_SILENT != f_run_mode)
fprintf(stdout,
"\nWARNING - Suite cleanup failed for %s.",
(NULL != pSuite->pName) ? pSuite->pName : "");
fprintf(stdout, _("\nWARNING - Suite cleanup failed for '%s'."), pSuite->pName);
}
/** @} */
This diff is collapsed.
This diff is collapsed.
......@@ -23,6 +23,8 @@
*
* 16-Jul-2004 Created access functions for error code, error action
* functions, messages for new error codes. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/
/** @file
......@@ -35,6 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "CUnit_intl.h"
#include "CUError.h"
/*=================================================================
......@@ -61,7 +64,7 @@ void CU_set_error(CU_ErrorCode error)
{
if ((error != CUE_SUCCESS) && (g_error_action == CUEA_ABORT)) {
#ifndef CUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS
fprintf(stderr, "\nAborting due to error #%d: %s\n",
fprintf(stderr, _("\nAborting due to error #%d: %s\n"),
(int)error,
get_error_desc(error));
exit((int)error);
......@@ -114,8 +117,8 @@ static const char* get_error_desc(CU_ErrorCode iError)
int iMaxIndex;
static const char* ErrorDescription[] = {
"No Error", /* CUE_SUCCESS - 0 */
"Memory allocation failed.", /* CUE_NOMEMORY - 1 */
N_("No Error."), /* CUE_SUCCESS - 0 */
N_("Memory allocation failed."), /* CUE_NOMEMORY - 1 */
"",
"",
"",
......@@ -124,8 +127,8 @@ static const char* get_error_desc(CU_ErrorCode iError)
"",
"",
"",
"Test registry does not exist.", /* CUE_NOREGISTRY - 10 */
"Registry already exists.", /* CUE_REGISTRY_EXISTS - 11 */
N_("Test registry does not exist."), /* CUE_NOREGISTRY - 10 */
N_("Registry already exists."), /* CUE_REGISTRY_EXISTS - 11 */
"",
"",
"",
......@@ -134,42 +137,42 @@ static const char* get_error_desc(CU_ErrorCode iError)
"",
"",
"",
"NULL suite not allowed.", /* CUE_NOSUITE - 20 */
"Suite name cannot be NULL.", /* CUE_NO_SUITENAME - 21 */
"Suite initialization function failed.", /* CUE_SINIT_FAILED - 22 */
"Suite cleanup function failed.", /* CUE_SCLEAN_FAILED - 23 */
"Suite having name already registered.", /* CUE_DUP_SUITE - 24 */
"Requested suite is not active.", /* CUE_SUITE_INACTIVE - 25 */
N_("NULL suite not allowed."), /* CUE_NOSUITE - 20 */
N_("Suite name cannot be NULL."), /* CUE_NO_SUITENAME - 21 */
N_("Suite initialization function failed."), /* CUE_SINIT_FAILED - 22 */
N_("Suite cleanup function failed."), /* CUE_SCLEAN_FAILED - 23 */
N_("Suite having name already registered."), /* CUE_DUP_SUITE - 24 */
N_("Requested suite is not active."), /* CUE_SUITE_INACTIVE - 25 */
"",
"",
"",
"",
"NULL test or test function not allowed.",/* CUE_NOTEST - 30 */
"Test name cannot be NULL.", /* CUE_NO_TESTNAME - 31 */
"Test having this name already in suite.",/* CUE_DUP_TEST - 32 */
"Test not registered in specified suite.",/* CUE_TEST_NOT_IN_SUITE - 33 */
"Requested test is not active", /* CUE_TEST_INACTIVE - 34 */
N_("NULL test or test function not allowed."),/* CUE_NOTEST - 30 */
N_("Test name cannot be NULL."), /* CUE_NO_TESTNAME - 31 */
N_("Test having this name already in suite."),/* CUE_DUP_TEST - 32 */
N_("Test not registered in specified suite."),/* CUE_TEST_NOT_IN_SUITE - 33 */
N_("Requested test is not active"), /* CUE_TEST_INACTIVE - 34 */
"",
"",
"",
"",
"",
"Error opening file.", /* CUE_FOPEN_FAILED - 40 */
"Error closing file.", /* CUE_FCLOSE_FAILED - 41 */
"Bad file name.", /* CUE_BAD_FILENAME - 42 */
"Error during write to file.", /* CUE_WRITE_ERROR - 43 */
"Undefined Error"
N_("Error opening file."), /* CUE_FOPEN_FAILED - 40 */
N_("Error closing file."), /* CUE_FCLOSE_FAILED - 41 */
N_("Bad file name."), /* CUE_BAD_FILENAME - 42 */
N_("Error during write to file."), /* CUE_WRITE_ERROR - 43 */
N_("Undefined Error")
};
iMaxIndex = (int)(sizeof(ErrorDescription)/sizeof(char *) - 1);
if ((int)iError < 0) {
return ErrorDescription[0];
return _(ErrorDescription[0]);
}
else if ((int)iError > iMaxIndex) {
return ErrorDescription[iMaxIndex];
return _(ErrorDescription[iMaxIndex]);
}
else {
return ErrorDescription[(int)iError];
return _(ErrorDescription[(int)iError]);
}
}
......
......@@ -33,6 +33,8 @@
*
* 24-Apr-2005 Changed type of allocated sizes to size_t to avoid
* signed-unsigned mismatch. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/
/** @file
......@@ -52,6 +54,7 @@
#include "CUnit.h"
#include "MyMem.h"
#include "CUNit_intl.h"
#ifdef MEMTRACE
......@@ -154,7 +157,7 @@ static PMEMORY_EVENT add_memory_event(PMEMORY_NODE pMemoryNode,
assert (NULL != pMemoryNode);
/* create and set up the new event */
pMemoryEvent = malloc(sizeof(MEMORY_EVENT));
pMemoryEvent = (PMEMORY_EVENT)malloc(sizeof(MEMORY_EVENT));
assert(NULL != pMemoryEvent);
pMemoryEvent->Size = size;
......@@ -333,7 +336,7 @@ void CU_dump_memory_usage(const char* szFilename)
}
if (NULL == (pFile = fopen(szDumpFileName, "w"))) {
fprintf(stderr, "Failed to open file \"%s\" : %s", szDumpFileName, strerror(errno));
fprintf(stderr, _("Failed to open file \"%s\" : %s"), szDumpFileName, strerror(errno));
return;
}
......
......@@ -21,27 +21,29 @@
/*
* Implementation of Registry/TestGroup/Testcase management Routines.
*
* Aug 2001 Initial implementation (AK)
* Aug 2001 Initial implementation (AK)
*
* 09/Aug/2001 Added startup initialize/cleanup registry functions. (AK)
* 09/Aug/2001 Added startup initialize/cleanup registry functions. (AK)
*
* 29/Aug/2001 Added Test and Group Add functions. (AK)
* 29/Aug/2001 Added Test and Group Add functions. (AK)
*
* 02/Oct/2001 Added Proper Error codes and Messages on the failure conditions. (AK)
* 02/Oct/2001 Added Proper Error codes and Messages on the failure conditions. (AK)
*
* 13/Oct/2001 Added Code to Check for the Duplicate Group name and test name. (AK)
* 13/Oct/2001 Added Code to Check for the Duplicate Group name and test name. (AK)
*
* 15-Jul-2004 Added doxygen comments, new interface, added assertions to
* internal functions, moved error handling code to CUError.c,
* added assertions to make sure no modification of registry
* during a run, bug fixes, changed CU_set_registry() so that it
* doesn't require cleaning the existing registry. (JDS)
* 15-Jul-2004 Added doxygen comments, new interface, added assertions to
* internal functions, moved error handling code to CUError.c,
* added assertions to make sure no modification of registry
* during a run, bug fixes, changed CU_set_registry() so that it
* doesn't require cleaning the existing registry. (JDS)
*
* 24-Apr-2006 Removed constraint that suites/tests be uniquely named.
* Added ability to turn individual tests/suites on or off.
* Added lookup functions for suites/tests based on index.
* Moved doxygen comments for public API here to header.
* Modified internal unit tests to include these changes. (JDS)
* 24-Apr-2006 Removed constraint that suites/tests be uniquely named.
* Added ability to turn individual tests/suites on or off.
* Added lookup functions for suites/tests based on index.
* Moved doxygen comments for public API here to header.
* Modified internal unit tests to include these changes. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/
/** @file
......@@ -62,6 +64,7 @@
#include "TestDB.h"
#include "TestRun.h"
#include "Util.h"
#include "CUnit_intl.h"
/*=================================================================
* Global/Static Definitions
......
......@@ -53,6 +53,8 @@
* Moved doxygen comments for public functions into header.
* Added type marker to CU_FailureRecord.
* Added support for tracking inactive suites/tests. (JDS)
*
* 02-May-2006 Added internationalization hooks. (JDS)
*/
/** @file
......@@ -72,6 +74,8 @@
#include "MyMem.h"
#include "TestDB.h"
#include "TestRun.h"
#include "Util.h"
#include "CUnit_intl.h"
/*=================================================================
* Global/Static Definitions
......@@ -309,7 +313,7 @@ CU_ErrorCode CU_run_all_tests(void)
f_run_summary.nSuitesInactive++;
if (CU_FALSE != f_failure_on_inactive) {
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInactive,
0, "Suite inactive", "CUnit System", pSuite, NULL);
0, _("Suite inactive"), _("CUnit System"), pSuite, NULL);
result = (CUE_SUCCESS == result) ? CUE_SUITE_INACTIVE : result;
}
}
......@@ -352,7 +356,7 @@ CU_ErrorCode CU_run_suite(CU_pSuite pSuite)
f_run_summary.nSuitesInactive++;
if (CU_FALSE != f_failure_on_inactive) {
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInactive,
0, "Suite inactive", "CUnit System", pSuite, NULL);
0, _("Suite inactive"), _("CUnit System"), pSuite, NULL);
result = (CUE_SUCCESS == result) ? CUE_SUITE_INACTIVE : result;
}
}
......@@ -388,7 +392,7 @@ CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest)
f_run_summary.nSuitesInactive++;
if (CU_FALSE != f_failure_on_inactive) {
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInactive,
0, "Suite inactive", "CUnit System", pSuite, NULL);
0, _("Suite inactive"), _("CUnit System"), pSuite, NULL);
}
result = CUE_SUITE_INACTIVE;
}
......@@ -399,7 +403,7 @@ CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest)
f_run_summary.nTestsInactive++;
if (CU_FALSE != f_failure_on_inactive) {
add_failure(&f_failure_list, &f_run_summary, CUF_TestInactive,
0, "Test inactive", "CUnit System", pSuite, pTest);
0, _("Test inactive"), _("CUnit System"), pSuite, pTest);
}
result = CUE_TEST_INACTIVE;
}
......@@ -415,8 +419,9 @@ CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest)
(*f_pSuiteInitFailureMessageHandler)(pSuite);
}
f_run_summary.nSuitesFailed++;
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInitFailed,
0, "Suite Initialization failed - Test Skipped", "CUnit System", pSuite, pTest);
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInitFailed, 0,
_("Suite Initialization failed - Test Skipped"),
_("CUnit System"), pSuite, pTest);
result = CUE_SINIT_FAILED;
/* test run is complete - clear flag */
f_bTestIsRunning = CU_FALSE;
......@@ -432,7 +437,7 @@ CU_ErrorCode CU_run_test(CU_pSuite pSuite, CU_pTest pTest)
}
f_run_summary.nSuitesFailed++;
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteCleanupFailed,
0, "Suite cleanup failed.", "CUnit System", pSuite, pTest);
0, _("Suite cleanup failed."), _("CUnit System"), pSuite, pTest);
result = (CUE_SUCCESS == result) ? CUE_SCLEAN_FAILED : result;
}
......@@ -488,6 +493,86 @@ CU_EXPORT CU_BOOL CU_get_fail_on_inactive(void)
}
/*------------------------------------------------------------------------*/
CU_EXPORT void CU_print_run_results(FILE *file)
{
CU_pRunSummary pRunSummary = &f_run_summary;
CU_pTestRegistry pRegistry = CU_get_registry();
size_t width[7];
assert(NULL != pRunSummary);
assert(NULL != pRegistry);
assert(NULL != file);
width[0] = strlen(_("Run Summary:"));
width[1] = CU_MAX(6,
CU_MAX(strlen(_("Type")),
CU_MAX(strlen(_("suites")),
CU_MAX(strlen(_("tests")),
strlen(_("asserts")))))) + 1;
width[2] = CU_MAX(6,
CU_MAX(strlen(_("Total")),
CU_MAX(CU_number_width(pRegistry->uiNumberOfSuites),
CU_MAX(CU_number_width(pRegistry->uiNumberOfTests),
CU_number_width(pRunSummary->nAsserts))))) + 1;
width[3] = CU_MAX(6,
CU_MAX(strlen(_("Ran")),
CU_MAX(CU_number_width(pRunSummary->nSuitesRun),
CU_MAX(CU_number_width(pRunSummary->nTestsRun),
CU_number_width(pRunSummary->nAsserts))))) + 1;
width[4] = CU_MAX(6,
CU_MAX(strlen(_("Passed")),
CU_MAX(strlen(_("n/a")),
CU_MAX(CU_number_width(pRunSummary->nTestsRun - pRunSummary->nTestsFailed),
CU_number_width(pRunSummary->nAsserts - pRunSummary->nAssertsFailed))))) + 1;
width[5] = CU_MAX(6,
CU_MAX(strlen(_("Failed")),
CU_MAX(CU_number_width(pRunSummary->nSuitesFailed),
CU_MAX(CU_number_width(pRunSummary->nTestsFailed),
CU_number_width(pRunSummary->nAssertsFailed))))) + 1;
width[6] = CU_MAX(6,
CU_MAX(strlen(_("Inactive")),
CU_MAX(CU_number_width(pRunSummary->nSuitesInactive),
CU_MAX(CU_number_width(pRunSummary->nTestsInactive),
strlen(_("n/a")))))) + 1;
fprintf(file, "\n\n %*s%*s%*s%*s%*s%*s%*s"
"\n %*s%*s%*u%*u%*s%*u%*u"
"\n %*s%*s%*u%*u%*u%*u%*u"
"\n %*s%*s%*u%*u%*u%*u%*s\n",
width[0], _("Run Summary:"),
width[1], _("Type"),
width[2], _("Total"),
width[3], _("Ran"),
width[4], _("Passed"),
width[5], _("Failed"),
width[6], _("Inactive"),
width[0], " ",
width[1], _("suites"),
width[2], pRegistry->uiNumberOfSuites,
width[3], pRunSummary->nSuitesRun,
width[4], _("n/a"),
width[5], pRunSummary->nSuitesFailed,
width[6], pRunSummary->nSuitesInactive,
width[0], " ",
width[1], _("tests"),
width[2], pRegistry->uiNumberOfTests,
width[3], pRunSummary->nTestsRun,
width[4], pRunSummary->nTestsRun - pRunSummary->nTestsFailed,
width[5], pRunSummary->nTestsFailed,
width[6], pRunSummary->nTestsInactive,
width[0], " ",
width[1], _("asserts"),
width[2], pRunSummary->nAsserts,
width[3], pRunSummary->nAsserts,
width[4], pRunSummary->nAsserts - pRunSummary->nAssertsFailed,
width[5], pRunSummary->nAssertsFailed,
width[6], _("n/a"));
}
/*=================================================================
* Static Function Definitions
*=================================================================*/
/**
* Records a runtime failure.
* This function is called whenever a runtime failure occurs.
......@@ -682,8 +767,9 @@ static CU_ErrorCode run_single_suite(CU_pSuite pSuite, CU_pRunSummary pRunSummar
(*f_pSuiteInitFailureMessageHandler)(pSuite);
}
pRunSummary->nSuitesFailed++;
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInitFailed,
0, "Suite Initialization failed - Suite Skipped", "CUnit System", pSuite, NULL);
add_failure(&f_failure_list, &f_run_summary, CUF_SuiteInitFailed, 0,
_("Suite Initialization failed - Suite Skipped"),
_("CUnit System"), pSuite, NULL);
result