mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
test failures can be ignored for certain tests (specified in CPPUNIT_IGNORE environment variable)
This commit is contained in:
parent
0cf0469596
commit
16885da987
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "CppUnit/CppUnit.h"
|
#include "CppUnit/CppUnit.h"
|
||||||
#include "CppUnit/TestResult.h"
|
#include "CppUnit/TestResult.h"
|
||||||
|
#include <set>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
@ -33,9 +34,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string shortName(const std::string& testName);
|
std::string shortName(const std::string& testName);
|
||||||
|
void setup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostream& _ostr;
|
std::ostream& _ostr;
|
||||||
|
std::set<std::string> _ignored;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "CppUnit/estring.h"
|
#include "CppUnit/estring.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
@ -19,26 +20,61 @@ namespace CppUnit {
|
|||||||
TextTestResult::TextTestResult():
|
TextTestResult::TextTestResult():
|
||||||
_ostr(std::cout)
|
_ostr(std::cout)
|
||||||
{
|
{
|
||||||
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TextTestResult::TextTestResult(std::ostream& ostr):
|
TextTestResult::TextTestResult(std::ostream& ostr):
|
||||||
_ostr(ostr)
|
_ostr(ostr)
|
||||||
{
|
{
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TextTestResult::setup()
|
||||||
|
{
|
||||||
|
const char* env = std::getenv("CPPUNIT_IGNORE");
|
||||||
|
if (env)
|
||||||
|
{
|
||||||
|
std::string ignored = env;
|
||||||
|
std::string::const_iterator it = ignored.begin();
|
||||||
|
std::string::const_iterator end = ignored.end();
|
||||||
|
while (it != end)
|
||||||
|
{
|
||||||
|
while (it != end && *it == ' ') ++it;
|
||||||
|
std::string test;
|
||||||
|
while (it != end && *it != ' ') test += *it++;
|
||||||
|
if (!test.empty()) _ignored.insert(test);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextTestResult::addError(Test* test, CppUnitException* e)
|
void TextTestResult::addError(Test* test, CppUnitException* e)
|
||||||
{
|
{
|
||||||
|
if (_ignored.find(test->toString()) == _ignored.end())
|
||||||
|
{
|
||||||
TestResult::addError(test, e);
|
TestResult::addError(test, e);
|
||||||
_ostr << "ERROR" << std::flush;
|
_ostr << "ERROR" << std::flush;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ostr << "ERROR (ignored)" << std::flush;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextTestResult::addFailure(Test* test, CppUnitException* e)
|
void TextTestResult::addFailure(Test* test, CppUnitException* e)
|
||||||
{
|
{
|
||||||
|
if (_ignored.find(test->toString()) == _ignored.end())
|
||||||
|
{
|
||||||
TestResult::addFailure(test, e);
|
TestResult::addFailure(test, e);
|
||||||
_ostr << "FAILURE" << std::flush;
|
_ostr << "FAILURE" << std::flush;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ostr << "FAILURE (ignored)" << std::flush;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user