Support for running the testsuite in command line programs for continuous integration.
Here is a small example inspired from SDLmain.c:
g_launcher = new JGameLauncher();
InitGame();
MTGCollection()->loadFolder("sets/primitives/");
MTGCollection()->loadFolder("sets/", "_cards.dat");
options.reloadProfile();
TestSuite testSuite("test/_tests.txt");
int result = testSuite.run();
DestroyGame();
delete g_launcher;
return result;
This commit is contained in:
@@ -531,7 +531,6 @@ TestSuite::TestSuite(const char * filename)
|
||||
|
||||
int TestSuite::loadNext()
|
||||
{
|
||||
|
||||
endTime = JGEGetTime();
|
||||
summoningSickness = 0;
|
||||
seed = 0;
|
||||
@@ -582,6 +581,43 @@ int TestSuite::loadNext()
|
||||
return currentfile;
|
||||
}
|
||||
|
||||
void TestSuite::ThreadProc(void* inParam)
|
||||
{
|
||||
LOG("Entering TestSuite::ThreadProc");
|
||||
TestSuite* instance = reinterpret_cast<TestSuite*>(inParam);
|
||||
if (instance)
|
||||
{
|
||||
string filename;
|
||||
float counter = 1.0f;
|
||||
while(instance->mProcessing && (filename = instance->getNextFile()) != "")
|
||||
{
|
||||
TestSuiteGame theGame(instance, filename);
|
||||
if(theGame.isOK)
|
||||
{
|
||||
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
||||
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
||||
|
||||
theGame.observer->startGame(theGame.gameType, /*instance->mRules*/Rules::getRulesByFilename("testsuite.txt"));
|
||||
theGame.initGame();
|
||||
|
||||
while(!theGame.observer->didWin())
|
||||
theGame.observer->Update(counter++);
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG("Leaving TestSuite::ThreadProc");
|
||||
}
|
||||
|
||||
int TestSuite::run()
|
||||
{
|
||||
mProcessing = false;
|
||||
loadNext();
|
||||
ThreadProc(this);
|
||||
|
||||
return nbFailed + nbAIFailed;
|
||||
}
|
||||
|
||||
|
||||
void TestSuiteActions::cleanup()
|
||||
{
|
||||
nbitems = 0;
|
||||
@@ -755,41 +791,6 @@ void TestSuite::pregameTests()
|
||||
}
|
||||
}
|
||||
|
||||
void TestSuite::ThreadProc(void* inParam)
|
||||
{
|
||||
LOG("Entering TestSuite::ThreadProc");
|
||||
TestSuite* instance = reinterpret_cast<TestSuite*>(inParam);
|
||||
if (instance)
|
||||
{
|
||||
string filename;
|
||||
while(instance->mProcessing && (filename = instance->getNextFile()) != "")
|
||||
{
|
||||
TestSuiteGame theGame(instance, filename);
|
||||
if(theGame.isOK)
|
||||
{
|
||||
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
||||
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
||||
|
||||
theGame.observer->startGame(theGame.gameType, instance->mRules);
|
||||
theGame.initGame();
|
||||
|
||||
while(!theGame.observer->didWin())
|
||||
theGame.observer->Update(1);
|
||||
/*
|
||||
if(theGame.observer->gameType() != GAME_TYPE_MOMIR)
|
||||
{
|
||||
stringstream stream;
|
||||
stream << *(theGame.observer);
|
||||
theGame.observer->load(stream.str(), false, &theGame);
|
||||
theGame.assertGame();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG("Leaving TestSuite::ThreadProc");
|
||||
}
|
||||
|
||||
boost::mutex TestSuiteGame::mMutex;
|
||||
|
||||
TestSuiteGame::~TestSuiteGame()
|
||||
|
||||
Reference in New Issue
Block a user