Merge branch 'master' into defines
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
// dirty, but I get OS header includes this way
|
||||
#include "JGE.h"
|
||||
|
||||
#include "OutputCapturer.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@@ -29,12 +31,23 @@ std::string ToHex(T* pointer)
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
|
||||
#ifdef QT_CONFIG
|
||||
|
||||
#ifdef CAPTURE_STDERR
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString; \
|
||||
qDebug("%s", stream.str().c_str()); \
|
||||
OutputCapturer::add(stream.str()); \
|
||||
}
|
||||
#else // CAPTURE_STDERR
|
||||
#define DebugTrace(inString) \
|
||||
{ \
|
||||
std::ostringstream stream; \
|
||||
stream << inString; \
|
||||
qDebug("%s", stream.str().c_str()); \
|
||||
}
|
||||
#endif // CAPTURE_STDERR
|
||||
|
||||
#elif defined (ANDROID)
|
||||
#include <android/log.h>
|
||||
#define DebugTrace(inString) \
|
||||
|
||||
23
JGE/include/OutputCapturer.h
Normal file
23
JGE/include/OutputCapturer.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef OUTPUTCAPTURER_H
|
||||
#define OUTPUTCAPTURER_H
|
||||
|
||||
#if defined(QT_CONFIG)
|
||||
#include <Qt>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "Threading.h"
|
||||
|
||||
class OutputCapturer
|
||||
{
|
||||
private:
|
||||
static std::ostringstream stream;
|
||||
static boost::mutex mMutex;
|
||||
|
||||
public:
|
||||
static void add(const std::string& s);
|
||||
static void debugAndClear();
|
||||
static void clear();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // OUTPUTCAPTURER_H
|
||||
@@ -315,7 +315,6 @@ namespace boost
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "../include/DebugRoutines.h"
|
||||
#include "../include/JLogger.h"
|
||||
|
||||
namespace boost
|
||||
|
||||
22
JGE/src/OutputCapturer.cpp
Normal file
22
JGE/src/OutputCapturer.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "../include/OutputCapturer.h"
|
||||
|
||||
std::ostringstream OutputCapturer::stream;
|
||||
boost::mutex OutputCapturer::mMutex;
|
||||
|
||||
void OutputCapturer::add(const std::string& s)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(mMutex);
|
||||
stream << s << "\n";
|
||||
}
|
||||
|
||||
void OutputCapturer::debugAndClear()
|
||||
{
|
||||
stream.flush();
|
||||
qDebug("%s", stream.str().c_str());
|
||||
stream.str("");
|
||||
}
|
||||
|
||||
void OutputCapturer::clear()
|
||||
{
|
||||
stream.str("");
|
||||
}
|
||||
@@ -96,7 +96,11 @@ int main(int argc, char* argv[])
|
||||
options.reloadProfile();
|
||||
TestSuite testSuite("test/_tests.txt");
|
||||
result = testSuite.run();
|
||||
int totalTests = testSuite.nbTests + testSuite.nbAITests;
|
||||
delete wagicCore;
|
||||
DebugTrace("TestSuite done: failed test: " << result);
|
||||
DebugTrace("TestSuite done: failed test: " << result << " out of " << totalTests << " total");
|
||||
#ifdef CAPTURE_STDERR
|
||||
OutputCapturer::debugAndClear();
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,15 @@ void TestSuiteGame::assertGame()
|
||||
Log("<span class=\"success\">==Test Succesful !==</span>");
|
||||
else
|
||||
Log("<span class=\"error\">==Test Failed !==</span>");
|
||||
#ifdef CAPTURE_STDERR
|
||||
if (error)
|
||||
{
|
||||
OutputCapturer::debugAndClear();
|
||||
} else
|
||||
{
|
||||
OutputCapturer::clear();
|
||||
}
|
||||
#endif
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -585,6 +594,9 @@ void TestSuite::ThreadProc(void* inParam)
|
||||
{
|
||||
LOG("Entering TestSuite::ThreadProc");
|
||||
TestSuite* instance = reinterpret_cast<TestSuite*>(inParam);
|
||||
#ifdef CAPTURE_STDERR
|
||||
OutputCapturer::debugAndClear();
|
||||
#endif
|
||||
if (instance)
|
||||
{
|
||||
string filename;
|
||||
|
||||
@@ -327,6 +327,7 @@ SOURCES += \
|
||||
../../JGE/src/pc/JSocket.cpp\
|
||||
../../JGE/src/pc/JSfx.cpp\
|
||||
../../JGE/src/JSprite.cpp\
|
||||
../../JGE/src/OutputCapturer.cpp\
|
||||
../../JGE/src/Vector2D.cpp\
|
||||
../../JGE/src/tinyxml/tinystr.cpp\
|
||||
../../JGE/src/tinyxml/tinyxml.cpp\
|
||||
@@ -393,6 +394,7 @@ HEADERS += \
|
||||
../../JGE/include/JSpline.h\
|
||||
../../JGE/include/JSprite.h\
|
||||
../../JGE/include/JTypes.h\
|
||||
../../JGE/include/OutputCapturer.h\
|
||||
../../JGE/include/Vector2D.h\
|
||||
../../JGE/include/Vector3D.h\
|
||||
../../JGE/include/vram.h\
|
||||
|
||||
@@ -10,7 +10,7 @@ make -j 8
|
||||
|
||||
# let's try an Intel linux binary
|
||||
cd ../..
|
||||
qmake projects/mtg/wagic-qt.pro CONFIG+=console CONFIG+=debug
|
||||
qmake projects/mtg/wagic-qt.pro CONFIG+=console CONFIG+=debug DEFINES+=CAPTURE_STDERR
|
||||
make -j 8
|
||||
|
||||
# and finish by running the testsuite
|
||||
|
||||
Reference in New Issue
Block a user