diff --git a/livesupport/products/scheduler/etc/Makefile.in b/livesupport/products/scheduler/etc/Makefile.in
index 60d0877aa..c813b4e9b 100644
--- a/livesupport/products/scheduler/etc/Makefile.in
+++ b/livesupport/products/scheduler/etc/Makefile.in
@@ -21,7 +21,7 @@
#
#
# 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 $
#
# @configure_input@
@@ -74,6 +74,10 @@ STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
STORAGE_LIB = livesupport_storage
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
TEST_RUNNER = ${TMP_DIR}/testRunner
@@ -140,6 +144,7 @@ clean:
docclean:
${RMDIR} ${DOXYGEN_DIR}/html
+ ${RM} ${TEST_RESULTS}
depclean: clean
@@ -147,7 +152,8 @@ distclean: clean docclean
${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te*
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}
#-------------------------------------------------------------------------------
diff --git a/livesupport/products/scheduler/etc/testResultToHtml.xsl b/livesupport/products/scheduler/etc/testResultToHtml.xsl
new file mode 100644
index 000000000..d2165c2a4
--- /dev/null
+++ b/livesupport/products/scheduler/etc/testResultToHtml.xsl
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+ LiveSupport unit test results
+
+
+Preface
+This document is part of the
+LiveSupport
+project, Copyright © 2004 Media
+Development Loan Fund, under the GNU
+GPL.
+
+This is an automatically generated document.
+Scope
+This document contains the generated unit test results for the
+LiveSupport project.
+Summary
+
+
+
+ Total number of tests: |
+ |
+
+
+ Tests passed: |
+ |
+
+
+ Tests failed: |
+ |
+
+
+ Test errors: |
+ |
+
+
+
+Tests
+
+
+ test name |
+ test status |
+
+
+
+
+ |
+ failed |
+ passed |
+
+
+
+
+
+
+
+
+
diff --git a/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx b/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx
index 6b0baafaa..8792dfec6 100644
--- a/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx
+++ b/livesupport/products/scheduler/src/PostgresqlScheduleTest.cxx
@@ -22,7 +22,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -142,7 +142,7 @@ PostgresqlScheduleTest :: simpleScheduleTest(void)
try {
schedule->schedulePlaylist(playlist, from);
} catch (std::invalid_argument &e) {
- CPPUNIT_ASSERT(e.what());
+ CPPUNIT_FAIL(e.what());
}
}
@@ -165,7 +165,7 @@ PostgresqlScheduleTest :: scheduleAndQueryTest(void)
try {
schedule->schedulePlaylist(playlist, from);
} catch (std::invalid_argument &e) {
- CPPUNIT_ASSERT(e.what());
+ CPPUNIT_FAIL(e.what());
}
// check for available timeframes around the inserted one
diff --git a/livesupport/products/scheduler/src/TestRunner.cxx b/livesupport/products/scheduler/src/TestRunner.cxx
index 0cf694cae..0d054220c 100644
--- a/livesupport/products/scheduler/src/TestRunner.cxx
+++ b/livesupport/products/scheduler/src/TestRunner.cxx
@@ -22,7 +22,7 @@
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 $
------------------------------------------------------------------------------*/
@@ -33,22 +33,107 @@
#include "configure.h"
#endif
+#if HAVE_UNISTD_H
+#include
+#else
+#error "Need unistd.h"
+#endif
+
+#if HAVE_GETOPT_H
+#include
+#else
+#error "Need getopt.h"
+#endif
+
+#include
+
#include
#include
+#include
#include
#include
#include
#include
+#include "LiveSupport/Core/Ptr.h"
+
+
+using namespace LiveSupport::Core;
/* =================================================== local data structures */
/* ================================================ 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::Ref xmlOutFileName;
+
+/**
+ * The XSLT attached to the output file.
+ */
+static Ptr::Ref xsltFileName;
+
/* =============================================== 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 */
@@ -59,6 +144,10 @@ int
main( int argc,
char * argv[] ) throw ()
{
+ if (!processArguments(argc, argv)) {
+ return 0;
+ }
+
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
@@ -79,7 +168,113 @@ main( int argc,
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
outputter.setLocationFormat("%p:%l:");
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;
}
+
+/*------------------------------------------------------------------------------
+ * 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;
+}
+