Stopped CLogger outputting error messages with debug_printf while in test cases that are intentionally triggering errors.
This was SVN commit r6259.
This commit is contained in:
parent
4a57fed5a7
commit
b979033385
@ -195,12 +195,16 @@ public:
|
||||
|
||||
void test_load_nonexistent_pmd()
|
||||
{
|
||||
TestLogger logger;
|
||||
|
||||
CModelDefPtr modeldef = meshManager->GetMesh(testPMD);
|
||||
TS_ASSERT(! modeldef);
|
||||
}
|
||||
|
||||
void test_load_nonexistent_dae()
|
||||
{
|
||||
TestLogger logger;
|
||||
|
||||
CModelDefPtr modeldef = meshManager->GetMesh(testDAE);
|
||||
TS_ASSERT(! modeldef);
|
||||
}
|
||||
|
@ -17,25 +17,20 @@ struct BlackHoleStreamBuf : public std::streambuf
|
||||
{
|
||||
} blackHoleStreamBuf;
|
||||
std::ostream blackHoleStream(&blackHoleStreamBuf);
|
||||
CLogger nullLogger(&blackHoleStream, &blackHoleStream, false);
|
||||
CLogger nullLogger(&blackHoleStream, &blackHoleStream, false, true);
|
||||
|
||||
CLogger* g_Logger = &nullLogger;
|
||||
|
||||
const char* html_header0 =
|
||||
"<!DOCTYPE HTML>\n" // HTML5 doctype - triggers standards mode in current browsers
|
||||
// (The W3C validator doesn't like it - use
|
||||
// http://hsivonen.iki.fi/validator/html5/ instead)
|
||||
"<!DOCTYPE HTML>\n"
|
||||
"<title>Pyrogenesis Log</title>\n"
|
||||
"<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">\n"
|
||||
"<p class=\"logo\"><img src=\"0adlogo.jpg\" alt=\"0 A.D.\"></p>\n"
|
||||
"<h1>";
|
||||
// (note that the html,head,body tags are optional)
|
||||
|
||||
const char* html_header1 = "</h1>\n";
|
||||
|
||||
const char* html_footer = "";
|
||||
// (</body> and </html> are optional too - this way we get the same valid
|
||||
// output even if we crash and don't close the file properly)
|
||||
|
||||
CLogger::CLogger()
|
||||
{
|
||||
@ -46,15 +41,17 @@ CLogger::CLogger()
|
||||
m_InterestingLog = new std::ofstream(interestinglogPath.external_file_string().c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
m_OwnsStreams = true;
|
||||
m_UseDebugPrintf = true;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
CLogger::CLogger(std::ostream* mainLog, std::ostream* interestingLog, bool takeOwnership)
|
||||
CLogger::CLogger(std::ostream* mainLog, std::ostream* interestingLog, bool takeOwnership, bool useDebugPrintf)
|
||||
{
|
||||
m_MainLog = mainLog;
|
||||
m_InterestingLog = interestingLog;
|
||||
m_OwnsStreams = takeOwnership;
|
||||
m_UseDebugPrintf = useDebugPrintf;
|
||||
|
||||
Init();
|
||||
}
|
||||
@ -123,6 +120,7 @@ void CLogger::WriteMessage(const char *message, int interestedness)
|
||||
void CLogger::WriteError(const char *message, int interestedness)
|
||||
{
|
||||
m_NumberOfErrors++;
|
||||
if (m_UseDebugPrintf)
|
||||
debug_printf("ERROR: %s\n", message);
|
||||
if (interestedness >= 1)
|
||||
{
|
||||
@ -234,7 +232,7 @@ int CLogger::Interestedness(const char* category)
|
||||
TestLogger::TestLogger()
|
||||
{
|
||||
m_OldLogger = g_Logger;
|
||||
g_Logger = new CLogger(&m_Stream, &blackHoleStream, false);
|
||||
g_Logger = new CLogger(&m_Stream, &blackHoleStream, false, false);
|
||||
}
|
||||
|
||||
TestLogger::~TestLogger()
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
|
||||
// Special constructor (mostly for testing) - outputs to provided streams.
|
||||
// Can take ownership of streams and delete them in the destructor.
|
||||
CLogger(std::ostream* mainLog, std::ostream* interestingLog, bool takeOwnership);
|
||||
CLogger(std::ostream* mainLog, std::ostream* interestingLog, bool takeOwnership, bool useDebugPrintf);
|
||||
|
||||
~CLogger();
|
||||
|
||||
@ -51,6 +51,10 @@ private:
|
||||
std::ostream* m_InterestingLog;
|
||||
bool m_OwnsStreams;
|
||||
|
||||
// whether errors should be reported via debug_printf (default)
|
||||
// or suppressed (for tests that intentionally trigger errors)
|
||||
bool m_UseDebugPrintf;
|
||||
|
||||
// vars to hold message counts
|
||||
int m_NumberOfMessages;
|
||||
int m_NumberOfErrors;
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
mainlog = new std::stringstream();
|
||||
interestinglog = new std::stringstream();
|
||||
|
||||
logger = new CLogger(mainlog, interestinglog, true);
|
||||
logger = new CLogger(mainlog, interestinglog, true, true);
|
||||
|
||||
lines.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user