rejigged things so that it doesn't core dump on exit. it's always nice when things exit cleanly

This commit is contained in:
jez 2008-04-16 22:10:01 +00:00
parent 22b58776e0
commit b569dbb43e
3 changed files with 136 additions and 115 deletions

View file

@ -20,87 +20,86 @@ int main(int argc, const char* argv[])
TestRunner runner;
// runner.addTest("ScopeTest", ScopeTest_suite<string_type, string_adaptor>());
// Xalan supplied test cases
/*
//runner.addTest("attribset", XSLTTest_suite("attribset"));
runner.addTest("attribvaltemplate", XSLTTest_suite("attribvaltemplate"));
runner.addTest("axes", XSLTTest_suite("axes"));
runner.addTest("boolean", XSLTTest_suite("boolean"));
runner.addTest("conditional", XSLTTest_suite("conditional"));
runner.addTest("conflictres", XSLTTest_suite("conflictres"));
runner.addTest("copy", XSLTTest_suite("copy"));
runner.addTest("dflt", XSLTTest_suite("dflt"));
runner.addTest("expression", XSLTTest_suite("expression"));
runner.addTest("extend", XSLTTest_suite("extend"));
//runner.addTest("idkey", XSLTTest_suite("idkey"));
runner.addTest("impincl", XSLTTest_suite("impincl"));
runner.addTest("lre", XSLTTest_suite("lre"));
runner.addTest("match", XSLTTest_suite("match"));
runner.addTest("math", XSLTTest_suite("math"));
runner.addTest("mdocs", XSLTTest_suite("mdocs"));
runner.addTest("message", XSLTTest_suite("message"));
runner.addTest("modes", XSLTTest_suite("modes"));
runner.addTest("namedtemplate", XSLTTest_suite("namedtemplate"));
runner.addTest("namespace", XSLTTest_suite("namespace"));
runner.addTest("node", XSLTTest_suite("node"));
//runner.addTest("numberformat", XSLTTest_suite("numberformat"));
//runner.addTest("numbering", XSLTTest_suite("numbering"));
runner.addTest("output", XSLTTest_suite("output"));
runner.addTest("position", XSLTTest_suite("position"));
runner.addTest("predicate", XSLTTest_suite("predicate"));
runner.addTest("processorinfo", XSLTTest_suite("processorinfo"));
runner.addTest("reluri", XSLTTest_suite("reluri"));
runner.addTest("select", XSLTTest_suite("select"));
runner.addTest("sort", XSLTTest_suite("sort"));
runner.addTest("string", XSLTTest_suite("string"));
runner.addTest("variable", XSLTTest_suite("variable"));
runner.addTest("ver", XSLTTest_suite("ver"));
runner.addTest("whitespace", XSLTTest_suite("whitespace"));
Loader loader;
// Xalan supplied test cases
//runner.addTest("attribset", loader.XSLTTest_suite("attribset"));
runner.addTest("attribvaltemplate", loader.XSLTTest_suite("attribvaltemplate"));
runner.addTest("axes", loader.XSLTTest_suite("axes"));
runner.addTest("boolean", loader.XSLTTest_suite("boolean"));
runner.addTest("conditional", loader.XSLTTest_suite("conditional"));
runner.addTest("conflictres", loader.XSLTTest_suite("conflictres"));
runner.addTest("copy", loader.XSLTTest_suite("copy"));
runner.addTest("dflt", loader.XSLTTest_suite("dflt"));
runner.addTest("expression", loader.XSLTTest_suite("expression"));
runner.addTest("extend", loader.XSLTTest_suite("extend"));
//runner.addTest("idkey", loader.XSLTTest_suite("idkey"));
runner.addTest("impincl", loader.XSLTTest_suite("impincl"));
runner.addTest("lre", loader.XSLTTest_suite("lre"));
runner.addTest("match", loader.XSLTTest_suite("match"));
runner.addTest("math", loader.XSLTTest_suite("math"));
runner.addTest("mdocs", loader.XSLTTest_suite("mdocs"));
runner.addTest("message", loader.XSLTTest_suite("message"));
runner.addTest("modes", loader.XSLTTest_suite("modes"));
runner.addTest("namedtemplate", loader.XSLTTest_suite("namedtemplate"));
runner.addTest("namespace", loader.XSLTTest_suite("namespace"));
runner.addTest("node", loader.XSLTTest_suite("node"));
//runner.addTest("numberformat", loader.XSLTTest_suite("numberformat"));
//runner.addTest("numbering", loader.XSLTTest_suite("numbering"));
runner.addTest("output", loader.XSLTTest_suite("output"));
runner.addTest("position", loader.XSLTTest_suite("position"));
runner.addTest("predicate", loader.XSLTTest_suite("predicate"));
runner.addTest("processorinfo", loader.XSLTTest_suite("processorinfo"));
runner.addTest("reluri", loader.XSLTTest_suite("reluri"));
runner.addTest("select", loader.XSLTTest_suite("select"));
runner.addTest("sort", loader.XSLTTest_suite("sort"));
runner.addTest("string", loader.XSLTTest_suite("string"));
runner.addTest("variable", loader.XSLTTest_suite("variable"));
runner.addTest("ver", loader.XSLTTest_suite("ver"));
runner.addTest("whitespace", loader.XSLTTest_suite("whitespace"));
// MSFT supplied test cases
runner.addTest("AVTs", XSLTTest_suite("AVTs"));
//runner.addTest("AttributeSets", XSLTTest_suite("AttributeSets"));
runner.addTest("Attributes", XSLTTest_suite("Attributes"));
runner.addTest("BVTs", XSLTTest_suite("BVTs"));
runner.addTest("Comment", XSLTTest_suite("Comment"));
runner.addTest("Completeness", XSLTTest_suite("Completeness"));
runner.addTest("ConflictResolution", XSLTTest_suite("ConflictResolution"));
runner.addTest("Copying", XSLTTest_suite("Copying"));
runner.addTest("Elements", XSLTTest_suite("Elements"));
runner.addTest("Errors", XSLTTest_suite("Errors"));
runner.addTest("Fallback", XSLTTest_suite("Fallback"));
runner.addTest("ForEach", XSLTTest_suite("ForEach"));
//runner.addTest("FormatNumber", XSLTTest_suite("FormatNumber"));
runner.addTest("ForwardComp", XSLTTest_suite("ForwardComp"));
//runner.addTest("Import", XSLTTest_suite("Import"));
//runner.addTest("Keys", XSLTTest_suite("Keys"));
runner.addTest("Messages", XSLTTest_suite("Messages"));
//runner.addTest("Miscellaneous", XSLTTest_suite("Miscellaneous"));
runner.addTest("Modes", XSLTTest_suite("Modes"));
//runner.addTest("NamedTemplates", XSLTTest_suite("NamedTemplates"));
//runner.addTest("Namespace", XSLTTest_suite("Namespace"));
//runner.addTest("Namespace-alias", XSLTTest_suite("Namespace-alias"));
//runner.addTest("Namespace_XPath", XSLTTest_suite("Namespace_XPath"));
//runner.addTest("Number", XSLTTest_suite("Number"));
//runner.addTest("Output", XSLTTest_suite("Output"));
*/
runner.addTest("ProcessingInstruction", XSLTTest_suite("ProcessingInstruction"));
runner.addTest("AVTs", loader.XSLTTest_suite("AVTs"));
//runner.addTest("AttributeSets", loader.XSLTTest_suite("AttributeSets"));
runner.addTest("Attributes", loader.XSLTTest_suite("Attributes"));
runner.addTest("BVTs", loader.XSLTTest_suite("BVTs"));
runner.addTest("Comment", loader.XSLTTest_suite("Comment"));
runner.addTest("Completeness", loader.XSLTTest_suite("Completeness"));
runner.addTest("ConflictResolution", loader.XSLTTest_suite("ConflictResolution"));
runner.addTest("Copying", loader.XSLTTest_suite("Copying"));
runner.addTest("Elements", loader.XSLTTest_suite("Elements"));
runner.addTest("Errors", loader.XSLTTest_suite("Errors"));
runner.addTest("Fallback", loader.XSLTTest_suite("Fallback"));
runner.addTest("ForEach", loader.XSLTTest_suite("ForEach"));
//runner.addTest("FormatNumber", loader.XSLTTest_suite("FormatNumber"));
runner.addTest("ForwardComp", loader.XSLTTest_suite("ForwardComp"));
//runner.addTest("Import", loader.XSLTTest_suite("Import"));
//runner.addTest("Keys", loader.XSLTTest_suite("Keys"));
runner.addTest("Messages", loader.XSLTTest_suite("Messages"));
//runner.addTest("Miscellaneous", loader.XSLTTest_suite("Miscellaneous"));
runner.addTest("Modes", loader.XSLTTest_suite("Modes"));
//runner.addTest("NamedTemplates", loader.XSLTTest_suite("NamedTemplates"));
//runner.addTest("Namespace", loader.XSLTTest_suite("Namespace"));
//runner.addTest("Namespace-alias", loader.XSLTTest_suite("Namespace-alias"));
//runner.addTest("Namespace_XPath", loader.XSLTTest_suite("Namespace_XPath"));
//runner.addTest("Number", loader.XSLTTest_suite("Number"));
//runner.addTest("Output", loader.XSLTTest_suite("Output"));
runner.addTest("ProcessingInstruction", loader.XSLTTest_suite("ProcessingInstruction"));
runner.addTest("RTF", XSLTTest_suite("RTF"));
runner.addTest("Sorting", XSLTTest_suite("Sorting"));
//runner.addTest("Stylesheet", XSLTTest_suite("Stylesheet"));
//runner.addTest("Template", XSLTTest_suite("Template"));
//runner.addTest("Text", XSLTTest_suite("Text"));
//runner.addTest("Valueof", XSLTTest_suite("Valueof"));
//runner.addTest("Variables", XSLTTest_suite("Variables"));
//runner.addTest("Whitespaces", XSLTTest_suite("Whitespaces"));
runner.addTest("XSLTFunctions", XSLTTest_suite("XSLTFunctions"));
runner.addTest("RTF", loader.XSLTTest_suite("RTF"));
runner.addTest("Sorting", loader.XSLTTest_suite("Sorting"));
//runner.addTest("Stylesheet", loader.XSLTTest_suite("Stylesheet"));
//runner.addTest("Template", loader.XSLTTest_suite("Template"));
//runner.addTest("Text", loader.XSLTTest_suite("Text"));
//runner.addTest("Valueof", loader.XSLTTest_suite("Valueof"));
//runner.addTest("Variables", loader.XSLTTest_suite("Variables"));
//runner.addTest("Whitespaces", loader.XSLTTest_suite("Whitespaces"));
runner.addTest("XSLTFunctions", loader.XSLTTest_suite("XSLTFunctions"));
runner.addTest("ArabicaErrors", ArabicaTest_suite("errors"));
runner.addTest("ArabicaInclude", ArabicaTest_suite("include"));
runner.addTest("ArabicaProcessingInstruction", ArabicaTest_suite("processing-instruction"));
runner.addTest("ArabicaStylesheets", ArabicaTest_suite("stylesheet"));
runner.addTest("ArabicaErrors", loader.ArabicaTest_suite("errors"));
runner.addTest("ArabicaInclude", loader.ArabicaTest_suite("include"));
runner.addTest("ArabicaProcessingInstruction", loader.ArabicaTest_suite("processing-instruction"));
runner.addTest("ArabicaStylesheets", loader.ArabicaTest_suite("stylesheet"));
runner.run(argc, argv);

View file

@ -1,19 +1,14 @@
#ifndef XSLT_XSLT_TEST_HPP
#define XSLT_XSLT_TEST_HPP
#pragma warning(disable: 4250)
#include <SAX/InputSource.hpp>
#include <SAX/Attributes.hpp>
#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <DOM/io/Stream.hpp>
#include <XSLT/XSLT.hpp>
#include <fstream>
#include "../CppUnit/framework/Test.h"
#include "../CppUnit/framework/TestCase.h"
#include "../CppUnit/framework/TestSuite.h"
#include "xslt_test.hpp"
#include <XSLT/XSLT.hpp>
//#include <elephant/newdelete.h>
//#include <elephant/memorymonitorholder.h>
//#include <elephant/leakdetector.h>
@ -576,38 +571,41 @@ private:
bool loaded_;
}; // class Expected
Expected& expected()
{
static Expected expected_fails;
if(!expected_fails.loaded())
expected_fails.load();
return expected_fails;
} // expected
Arabica::DOM::Document<std::string> loadCatalog(const std::string& catalog_filename)
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
Loader::Loader() :
expected_fails_(new Expected())
{
expected_fails_->load();
} // Loader
Loader::~Loader()
{
static std::map<std::string, Arabica::DOM::Document<std::string> > catalogs;
Arabica::DOM::Document<std::string> c = catalogs[catalog_filename];
delete expected_fails_;
} // ~Loader
Arabica::DOM::Document<std::string> Loader::loadCatalog(const std::string& catalog_filename)
{
Arabica::DOM::Document<std::string> c = catalogs_[catalog_filename];
if(c == 0)
{
std::cout << "Loading " << catalog_filename << std::endl;
c = buildDOM(PATH_PREFIX + catalog_filename);
catalogs[catalog_filename] = c;
} // if(c == 0)
catalogs_[catalog_filename] = c;
} // if(c == 0)
return c;
} // catalog
TestSuite* suite(const std::string& path,
const std::string& catalog_filename)
TestSuite* Loader::suite(const std::string& path, const std::string& catalog_filename)
{
Arabica::DOM::Document<std::string> catalog = loadCatalog(catalog_filename);
TestSuite *suiteOfTests = new TestSuite;
Arabica::XPath::NodeSet<std::string> tests =
selectNodes("/test-suite/test-catalog/test-case[file-path='" + path + "']", catalog);
selectNodes("/test-suite/test-catalog/test-case[file-path='" + path + "']", catalog);
std::cout << "There are " << tests.size() << " " << path << " tests." << std::endl;
for(int i = 0; i != tests.size(); ++i)
{
@ -619,7 +617,7 @@ TestSuite* suite(const std::string& path,
std::string input_xslt = selectString(".//input-file[@role='principal-stylesheet']", tests[i]);
std::string output_xml = selectString(".//output-file[@role='principal']", tests[i]);
if(expected().Fails().find(name) == expected().Fails().end())
if(expected_fails_->Fails().find(name) == expected_fails_->Fails().end())
{
if(operation == "execution-error")
suiteOfTests->addTest(new ExecutionErrorTest(name,
@ -631,40 +629,39 @@ TestSuite* suite(const std::string& path,
make_path(path, input_xslt),
make_path(out_path, output_xml)));
}
else if(expected().Fails()[name] == "compile")
else if(expected_fails_->Fails()[name] == "compile")
suiteOfTests->addTest(new CompileFailsTest(name,
make_path(path, input_xslt),
expected().Reasons()[name]));
else if(expected().Fails()[name] == "run")
expected_fails_->Reasons()[name]));
else if(expected_fails_->Fails()[name] == "run")
suiteOfTests->addTest(new RunFailsTest(name,
make_path(path, input_xml),
make_path(path, input_xslt),
expected().Reasons()[name]));
else if(expected().Fails()[name] == "skip")
suiteOfTests->addTest(new SkipTest(name, expected().Reasons()[name]));
else if(expected().Fails()[name] == "text")
expected_fails_->Reasons()[name]));
else if(expected_fails_->Fails()[name] == "skip")
suiteOfTests->addTest(new SkipTest(name, expected_fails_->Reasons()[name]));
else if(expected_fails_->Fails()[name] == "text")
suiteOfTests->addTest(new CompareAsTextXSLTTest(name,
make_path(path, input_xml),
make_path(path, input_xslt),
make_path(out_path, output_xml)));
else if(expected().Fails()[name] == "fragment")
else if(expected_fails_->Fails()[name] == "fragment")
suiteOfTests->addTest(new CompareAsXMLFragmentXSLTTest(name,
make_path(path, input_xml),
make_path(path, input_xslt),
make_path(out_path, output_xml)));
} // for ...
return suiteOfTests;
return suiteOfTests;
} // suite
TestSuite* XSLTTest_suite(const std::string& path)
TestSuite* Loader::XSLTTest_suite(const std::string& path)
{
return suite(path, "catalog.xml");
} // XSLTTest_suite
TestSuite* ArabicaTest_suite(const std::string& path)
TestSuite* Loader::ArabicaTest_suite(const std::string& path)
{
return suite(path, "arabica-catalog.xml");
} // ArabicaTest_suite
#endif

View file

@ -1,7 +1,32 @@
#ifndef XSLT_XSLT_TEST_HPP
#define XSLT_XSLT_TEST_HPP
TestSuite* XSLTTest_suite(const std::string& path);
TestSuite* ArabicaTest_suite(const std::string& path);
#include <map>
#include <string>
#include <SAX/InputSource.hpp>
#include <SAX/Attributes.hpp>
#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <DOM/io/Stream.hpp>
#include <fstream>
class Expected;
class Loader
{
public:
Loader();
~Loader();
TestSuite* XSLTTest_suite(const std::string& path);
TestSuite* ArabicaTest_suite(const std::string& path);
private:
Expected* expected_fails_;
std::map<std::string, Arabica::DOM::Document<std::string> > catalogs_;
Arabica::DOM::Document<std::string> loadCatalog(const std::string& catalog_filename);
TestSuite* suite(const std::string& path, const std::string& catalog_filename);
};
#endif