XSLT expected fail tests now output reason

This commit is contained in:
jez 2007-11-09 22:55:04 +00:00
parent 95cd084e0e
commit 7dd33fdd50

View file

@ -7,6 +7,11 @@
#include <XSLT/XSLT.hpp> #include <XSLT/XSLT.hpp>
#include <fstream> #include <fstream>
#include <elephant/newdelete.h>
#include <elephant/memorymonitorholder.h>
#include <elephant/leakdetector.h>
#include <elephant/leakdisplayfunc.h>
#ifdef ARABICA_WINDOWS #ifdef ARABICA_WINDOWS
const std::string PATH_PREFIX="../tests/XSLT/testsuite/TESTS/"; const std::string PATH_PREFIX="../tests/XSLT/testsuite/TESTS/";
const std::string SEPERATOR = "/"; const std::string SEPERATOR = "/";
@ -80,9 +85,11 @@ class CompileFailsTest : public TestCase
{ {
public: public:
CompileFailsTest(const std::string& name, CompileFailsTest(const std::string& name,
const std::string& input_xslt) : const std::string& input_xslt,
const std::string& reason) :
TestCase(name), TestCase(name),
input_xslt_(input_xslt) input_xslt_(input_xslt),
reason_(reason)
{ {
} // CompileFailsTest } // CompileFailsTest
@ -95,11 +102,12 @@ protected:
std::auto_ptr<Arabica::XSLT::Stylesheet> stylesheet = compiler.compile(source); std::auto_ptr<Arabica::XSLT::Stylesheet> stylesheet = compiler.compile(source);
if(stylesheet.get() != 0) if(stylesheet.get() != 0)
assertImplementation(false, "Expected " + input_xslt_ + " not to compile. But it did :o"); assertImplementation(false, "Expected " + input_xslt_ + " not to compile. But it did :o");
throw SkipException(compiler.error()); throw SkipException(reason_ + " : " + compiler.error());
} // runTest } // runTest
private: private:
std::string input_xslt_; std::string input_xslt_;
std::string reason_;
}; // CompileFailsTest }; // CompileFailsTest
class RunFailsTest : public TestCase class RunFailsTest : public TestCase
@ -107,10 +115,12 @@ class RunFailsTest : public TestCase
public: public:
RunFailsTest(const std::string& name, RunFailsTest(const std::string& name,
const std::string& input_xml, const std::string& input_xml,
const std::string& input_xslt) : const std::string& input_xslt,
const std::string& reason) :
TestCase(name), TestCase(name),
input_xml_(input_xml), input_xml_(input_xml),
input_xslt_(input_xslt) input_xslt_(input_xslt),
reason_(reason)
{ {
} // RunFailsTest } // RunFailsTest
@ -135,7 +145,7 @@ protected:
stylesheet->execute(document); stylesheet->execute(document);
} }
catch(const std::exception& e) { catch(const std::exception& e) {
throw SkipException(e.what()); throw SkipException(reason_ + " : " + e.what());
} }
assertImplementation(false, "Expected " + input_xslt_ + " to fail to execute. But it did :o"); assertImplementation(false, "Expected " + input_xslt_ + " to fail to execute. But it did :o");
} // runTest } // runTest
@ -143,6 +153,7 @@ protected:
private: private:
std::string input_xml_; std::string input_xml_;
std::string input_xslt_; std::string input_xslt_;
std::string reason_;
}; // RunFailsTest }; // RunFailsTest
class CompareAsTextXSLTTest : public TestCase class CompareAsTextXSLTTest : public TestCase
@ -352,27 +363,37 @@ public:
else if(runs == "no") else if(runs == "no")
fails[name] = "run"; fails[name] = "run";
else if(skip == "yes") else if(skip == "yes")
{
fails[name] = "skip"; fails[name] = "skip";
skips[name] = reason;
}
else if(compare == "text") else if(compare == "text")
fails[name] = "text"; fails[name] = "text";
reasons[name] = reason;
} // for ... } // for ...
} }
std::map<std::string, std::string>& Fails() { return fails; } std::map<std::string, std::string>& Fails() { return fails; }
std::map<std::string, std::string>& Skips() { return skips; } std::map<std::string, std::string>& Reasons() { return reasons; }
private: private:
std::map<std::string, std::string> fails; std::map<std::string, std::string> fails;
std::map<std::string, std::string> skips; std::map<std::string, std::string> reasons;
}; };
static Expected expected; static Expected expected;
TestSuite* XSLTTest_suite(const std::string& path) TestSuite* XSLTTest_suite(const std::string& path)
{ {
//#define new ELEPHANTNEW
// using namespace elephant;
// LeakDetector leakDetector;
// MemoryMonitorHolder().Instance().AddObserver(&leakDetector);
//
// poo();
//
// MemoryMonitorHolder().Instance().RemoveObserver(&leakDetector);
// LeakDisplayFunc leakDisplay(std::cout);
// std::for_each(leakDetector.begin(), leakDetector.end(), leakDisplay);
//#undef new
static Arabica::DOM::Document<std::string> catalog = buildDOM(PATH_PREFIX + "catalog.xml"); static Arabica::DOM::Document<std::string> catalog = buildDOM(PATH_PREFIX + "catalog.xml");
TestSuite *suiteOfTests = new TestSuite; TestSuite *suiteOfTests = new TestSuite;
@ -397,13 +418,15 @@ TestSuite* XSLTTest_suite(const std::string& path)
make_path(out_path, output_xml))); make_path(out_path, output_xml)));
else if(expected.Fails()[name] == "compile") else if(expected.Fails()[name] == "compile")
suiteOfTests->addTest(new CompileFailsTest(name, suiteOfTests->addTest(new CompileFailsTest(name,
make_path(path, input_xslt))); make_path(path, input_xslt),
expected.Reasons()[name]));
else if(expected.Fails()[name] == "run") else if(expected.Fails()[name] == "run")
suiteOfTests->addTest(new RunFailsTest(name, suiteOfTests->addTest(new RunFailsTest(name,
make_path(path, input_xml), make_path(path, input_xml),
make_path(path, input_xslt))); make_path(path, input_xslt),
expected.Reasons()[name]));
else if(expected.Fails()[name] == "skip") else if(expected.Fails()[name] == "skip")
suiteOfTests->addTest(new SkipTest(name, expected.Skips()[name])); suiteOfTests->addTest(new SkipTest(name, expected.Reasons()[name]));
else if(expected.Fails()[name] == "text") else if(expected.Fails()[name] == "text")
suiteOfTests->addTest(new CompareAsTextXSLTTest(name, suiteOfTests->addTest(new CompareAsTextXSLTTest(name,
make_path(path, input_xml), make_path(path, input_xml),