Fixed compilation on Windows and avoid crashing when the TestSuite is interrupted.
This commit is contained in:
@@ -60,7 +60,7 @@ protected:
|
||||
bool load();
|
||||
|
||||
public:
|
||||
~TestSuiteGame();
|
||||
virtual ~TestSuiteGame();
|
||||
TestSuiteGame(TestSuite* testsuite);
|
||||
TestSuiteGame(TestSuite* testsuite, string _filename);
|
||||
void initGame();
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
unsigned int seed;
|
||||
int nbFailed, nbTests, nbAIFailed, nbAITests;
|
||||
TestSuite(const char * filename);
|
||||
~TestSuite();
|
||||
void initGame(GameObserver* g);
|
||||
void pregameTests();
|
||||
int loadNext();
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "DamagerDamaged.h"
|
||||
|
||||
class CardView;
|
||||
class AttackerDamaged;
|
||||
class DamagerDamaged;
|
||||
struct AttackerDamaged;
|
||||
struct DamagerDamaged;
|
||||
typedef DamagerDamaged DefenserDamaged;
|
||||
|
||||
template<class T> void trash(T*);
|
||||
|
||||
@@ -447,11 +447,23 @@ void TestSuite::handleResults(bool wasAI, int error)
|
||||
}
|
||||
}
|
||||
|
||||
TestSuite::~TestSuite()
|
||||
{
|
||||
mProcessing = false;
|
||||
while(mWorkerThread.size())
|
||||
{
|
||||
mWorkerThread.back().join();
|
||||
mWorkerThread.pop_back();
|
||||
}
|
||||
|
||||
observer = 0;
|
||||
}
|
||||
|
||||
TestSuite::TestSuite(const char * filename)
|
||||
: TestSuiteGame(this), mRules(0), mProcessing(false)
|
||||
: TestSuiteGame(0), mRules(0), mProcessing(false)
|
||||
{
|
||||
timerLimit = 0;
|
||||
testsuite = this;
|
||||
|
||||
std::string s;
|
||||
nbfiles = 0;
|
||||
@@ -731,25 +743,20 @@ void TestSuite::ThreadProc(void* inParam)
|
||||
{
|
||||
string filename;
|
||||
float counter = 1.0f;
|
||||
// while(instance->mProcessing)
|
||||
while(instance->mProcessing && (filename = instance->getNextFile()) != "")
|
||||
{
|
||||
while((filename = instance->getNextFile()) != "")
|
||||
TestSuiteGame theGame(instance, filename);
|
||||
if(theGame.isOK)
|
||||
{
|
||||
TestSuiteGame theGame(instance, filename);
|
||||
if(theGame.isOK)
|
||||
{
|
||||
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
||||
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
||||
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
||||
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
||||
|
||||
theGame.observer->startGame(theGame.gameType, instance->mRules);
|
||||
theGame.initGame();
|
||||
theGame.observer->startGame(theGame.gameType, instance->mRules);
|
||||
theGame.initGame();
|
||||
|
||||
while(!theGame.observer->gameOver)
|
||||
theGame.observer->Update(counter++);
|
||||
}
|
||||
while(!theGame.observer->gameOver)
|
||||
theGame.observer->Update(counter++);
|
||||
}
|
||||
|
||||
boost::this_thread::sleep(100);
|
||||
}
|
||||
}
|
||||
LOG("Leaving TestSuite::ThreadProc");
|
||||
|
||||
Reference in New Issue
Block a user