added XML test reporting
This commit is contained in:
parent
90e8e8be5c
commit
382753c6b7
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: maroy $
|
# Author : $Author: maroy $
|
||||||
# Version : $Revision: 1.1 $
|
# Version : $Revision: 1.2 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/etc/Makefile.in,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -74,6 +74,10 @@ STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
||||||
STORAGE_LIB = livesupport_storage
|
STORAGE_LIB = livesupport_storage
|
||||||
STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a
|
STORAGE_LIB_FILE = ${STORAGE_LIB_DIR}/lib${STORAGE_LIB}.a
|
||||||
|
|
||||||
|
TEST_RESULTS = ${DOC_DIR}/testResults.xml
|
||||||
|
# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR
|
||||||
|
TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||||
|
|
||||||
SCHEDULER_EXE = ${TMP_DIR}/scheduler
|
SCHEDULER_EXE = ${TMP_DIR}/scheduler
|
||||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||||
|
|
||||||
|
@ -140,6 +144,7 @@ clean:
|
||||||
|
|
||||||
docclean:
|
docclean:
|
||||||
${RMDIR} ${DOXYGEN_DIR}/html
|
${RMDIR} ${DOXYGEN_DIR}/html
|
||||||
|
${RM} ${TEST_RESULTS}
|
||||||
|
|
||||||
depclean: clean
|
depclean: clean
|
||||||
|
|
||||||
|
@ -147,7 +152,8 @@ distclean: clean docclean
|
||||||
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
|
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
|
||||||
|
|
||||||
check: all ${TEST_RUNNER}
|
check: all ${TEST_RUNNER}
|
||||||
LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER}
|
LD_LIBRARY_PATH=${USR_LIB_DIR} ${TEST_RUNNER} \
|
||||||
|
-o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:template match="/">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>LiveSupport unit test results</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Preface</h1>
|
||||||
|
This document is part of the
|
||||||
|
<a href="http://livesupport.campware.org/">LiveSupport</a>
|
||||||
|
project, Copyright © 2004 <a href="http://www.mdlf.org/">Media
|
||||||
|
Development Loan Fund</a>, under the GNU
|
||||||
|
<a href="http://www.gnu.org/licenses/gpl.html">GPL</a>.
|
||||||
|
<br/>
|
||||||
|
This is an automatically generated document.
|
||||||
|
<h1>Scope</h1>
|
||||||
|
This document contains the generated unit test results for the
|
||||||
|
<a href="http://livesupport.campware.org/">LiveSupport</a> project.
|
||||||
|
<h1>Summary</h1>
|
||||||
|
<xsl:for-each select="//Statistics">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td><b>Total number of tests:</b></td>
|
||||||
|
<td><xsl:value-of select="Tests"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Tests passed:</b></td>
|
||||||
|
<td><xsl:value-of select="count(/*/SuccessfulTests/Test)"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Tests failed:</b></td>
|
||||||
|
<td><xsl:value-of select="Failures"/></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Test errors:</b></td>
|
||||||
|
<td><xsl:value-of select="Errors"/></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</xsl:for-each>
|
||||||
|
<h1>Tests</h1>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>test name</th>
|
||||||
|
<th>test status</th>
|
||||||
|
</tr>
|
||||||
|
<xsl:for-each select="//Test | //FailedTest">
|
||||||
|
<xsl:sort select="Name"/>
|
||||||
|
<tr>
|
||||||
|
<td><xsl:value-of select="Name"/></td>
|
||||||
|
<xsl:if test="ancestor::FailedTests"><td bgcolor="red">failed</td></xsl:if>
|
||||||
|
<xsl:if test="ancestor::SuccessfulTests"><td bgcolor="lightblue">passed</td></xsl:if>
|
||||||
|
</tr>
|
||||||
|
</xsl:for-each>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -142,7 +142,7 @@ PostgresqlScheduleTest :: simpleScheduleTest(void)
|
||||||
try {
|
try {
|
||||||
schedule->schedulePlaylist(playlist, from);
|
schedule->schedulePlaylist(playlist, from);
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
CPPUNIT_ASSERT(e.what());
|
CPPUNIT_FAIL(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ PostgresqlScheduleTest :: scheduleAndQueryTest(void)
|
||||||
try {
|
try {
|
||||||
schedule->schedulePlaylist(playlist, from);
|
schedule->schedulePlaylist(playlist, from);
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
CPPUNIT_ASSERT(e.what());
|
CPPUNIT_FAIL(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for available timeframes around the inserted one
|
// check for available timeframes around the inserted one
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/TestRunner.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/TestRunner.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -33,22 +33,107 @@
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#error "Need unistd.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_GETOPT_H
|
||||||
|
#include <getopt.h>
|
||||||
|
#else
|
||||||
|
#error "Need getopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include <cppunit/BriefTestProgressListener.h>
|
#include <cppunit/BriefTestProgressListener.h>
|
||||||
#include <cppunit/CompilerOutputter.h>
|
#include <cppunit/CompilerOutputter.h>
|
||||||
|
#include <cppunit/XmlOutputter.h>
|
||||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||||
#include <cppunit/TestResult.h>
|
#include <cppunit/TestResult.h>
|
||||||
#include <cppunit/TestResultCollector.h>
|
#include <cppunit/TestResultCollector.h>
|
||||||
#include <cppunit/TestRunner.h>
|
#include <cppunit/TestRunner.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
/* =================================================== local data structures */
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
/* ================================================ local constants & macros */
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our copyright notice, should be at most 80 columns
|
||||||
|
*/
|
||||||
|
static const char copyrightNotice[] =
|
||||||
|
"Copyright (c) 2004 Media Development Loan Fund under the GNU GPL";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String describing the short options.
|
||||||
|
*/
|
||||||
|
static const char options[] = "ho:s:v";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure describing the long options
|
||||||
|
*/
|
||||||
|
static const struct option longOptions[] = {
|
||||||
|
{ "help", no_argument, 0, 'h' },
|
||||||
|
{ "output", required_argument, 0, 'o' },
|
||||||
|
{ "stylesheet", required_argument, 0, 's' },
|
||||||
|
{ "version", no_argument, 0, 'v' },
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The encoding to use for the output file.
|
||||||
|
*/
|
||||||
|
static const std::string encoding = "utf-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output XML file name.
|
||||||
|
*/
|
||||||
|
static Ptr<std::string>::Ref xmlOutFileName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XSLT attached to the output file.
|
||||||
|
*/
|
||||||
|
static Ptr<std::string>::Ref xsltFileName;
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print program version.
|
||||||
|
*
|
||||||
|
* @param os the std::ostream to print to.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
printVersion ( std::ostream & os );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print program usage information.
|
||||||
|
*
|
||||||
|
* @param invocation the command line command used to invoke this program.
|
||||||
|
* @param os the std::ostream to print to.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
printUsage ( const char invocation[],
|
||||||
|
std::ostream & os );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process command line arguments.
|
||||||
|
*
|
||||||
|
* @param argc the number of arguments.
|
||||||
|
* @param argv the arguments themselves.
|
||||||
|
* @return true of all went well, false in case the program should exit
|
||||||
|
* after this call.
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
processArguments(int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================= module code */
|
/* ============================================================= module code */
|
||||||
|
|
||||||
|
@ -59,6 +144,10 @@ int
|
||||||
main( int argc,
|
main( int argc,
|
||||||
char * argv[] ) throw ()
|
char * argv[] ) throw ()
|
||||||
{
|
{
|
||||||
|
if (!processArguments(argc, argv)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the event manager and test controller
|
// Create the event manager and test controller
|
||||||
CPPUNIT_NS::TestResult controller;
|
CPPUNIT_NS::TestResult controller;
|
||||||
|
|
||||||
|
@ -79,7 +168,113 @@ main( int argc,
|
||||||
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
|
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
|
||||||
outputter.setLocationFormat("%p:%l:");
|
outputter.setLocationFormat("%p:%l:");
|
||||||
outputter.write();
|
outputter.write();
|
||||||
|
|
||||||
|
// also generate an XML document as an output
|
||||||
|
std::ofstream xmlOutFile(xmlOutFileName->c_str());
|
||||||
|
CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding);
|
||||||
|
if (xsltFileName) {
|
||||||
|
xmlOutputter.setStyleSheet(*xsltFileName);
|
||||||
|
}
|
||||||
|
xmlOutputter.write();
|
||||||
|
xmlOutFile.flush();
|
||||||
|
xmlOutFile.close();
|
||||||
|
|
||||||
return result.wasSuccessful() ? 0 : 1;
|
return result.wasSuccessful() ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Process command line arguments.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static bool
|
||||||
|
processArguments(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
|
||||||
|
switch (i) {
|
||||||
|
case 'h':
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case 'o':
|
||||||
|
xmlOutFileName.reset(new std::string(optarg));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
xsltFileName.reset(new std::string(optarg));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
printVersion(std::cout);
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc) {
|
||||||
|
std::cerr << "error processing command line arguments" << std::endl;
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xmlOutFileName) {
|
||||||
|
std::cerr << "mandatory option output file name not specified"
|
||||||
|
<< std::endl;
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl;
|
||||||
|
if (xsltFileName) {
|
||||||
|
std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Print program version.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
printVersion ( std::ostream & os )
|
||||||
|
{
|
||||||
|
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||||
|
<< "Unit test runner" << std::endl
|
||||||
|
<< copyrightNotice << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Print program usage.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
printUsage ( const char invocation[],
|
||||||
|
std::ostream & os )
|
||||||
|
{
|
||||||
|
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||||
|
<< "Unit test runner" << std::endl
|
||||||
|
<< std::endl
|
||||||
|
<< "Usage: " << invocation << " [OPTION]"
|
||||||
|
<< std::endl
|
||||||
|
<< " mandatory options:" << std::endl
|
||||||
|
<< " -o, --output=file.name write test results into this XML file"
|
||||||
|
<< std::endl
|
||||||
|
<< " optional options:" << std::endl
|
||||||
|
<< " -s, --stylesheet specify this XSLT for the output file"
|
||||||
|
<< std::endl
|
||||||
|
<< " this is either an absolute URI, or a"
|
||||||
|
<< std::endl
|
||||||
|
<< " relative path for the output document"
|
||||||
|
<< std::endl
|
||||||
|
<< " -h, --help display this help and exit" << std::endl
|
||||||
|
<< " -v, --version display version information and exit"
|
||||||
|
<< std::endl
|
||||||
|
<< std::endl
|
||||||
|
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue