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:
Xawotihs@gmail.com
2013-10-23 22:08:30 +00:00
parent 98861dd916
commit 1f0485ff8e
6 changed files with 99 additions and 52 deletions
+3 -2
View File
@@ -125,6 +125,8 @@ public:
#endif
MTGCard * getCardByName(string name);
void loadFolder(const string& folder, const string& filename="" );
int load(const char * config_file, const char * setName = NULL, int autoload = 1);
int countByType(const char * _type);
int countByColor(int color);
@@ -181,9 +183,8 @@ public:
return instance->subtypesList.find(value,false);
}
static void loadInstance();
static void unloadAll();
static inline MTGAllCards* getInstance() { return instance; };
static MTGAllCards* getInstance();
private:
boost::mutex mMutex;
+18 -11
View File
@@ -85,26 +85,33 @@ private:
void cleanup();
vector<boost::thread*> mWorkerThread;
Rules* mRules;
bool mProcessing;
public:
bool mProcessing;
int startTime, endTime;
unsigned int seed;
int nbFailed, nbTests, nbAIFailed, nbAITests;
TestSuite(const char * filename);
~TestSuite();
void initGame(GameObserver* g);
void pregameTests();
int loadNext();
static void ThreadProc(void* inParam);
string getNextFile() {
boost::mutex::scoped_lock lock(mMutex);
if (currentfile >= nbfiles) return "";
currentfile++;
return files[currentfile - 1];
};
static void ThreadProc(void* inParam);
void setRules(Rules* rules) {mRules = rules;};
void pregameTests();
public:
int getElapsedTime() {return endTime-startTime;};
unsigned int seed;
int nbFailed, nbTests, nbAIFailed, nbAITests;
TestSuite(const char * filename);
~TestSuite();
void initGame(GameObserver* g);
int loadNext();
void setRules(Rules* rules) {
mRules = rules;
};
void handleResults(bool wasAI, int error);
// run the test suite in turbo mode without UI,
// returns the amount of failed tests (AI or not), so 0 if everything went fine.
int run();
};
class TestSuiteAI:public AIPlayerBaka