Minor refactorings.
This commit is contained in:
parent
d9ce7a4a40
commit
736c0e2a65
1 changed files with 42 additions and 45 deletions
|
@ -255,7 +255,8 @@ ExecuteTest(void *suite, TestCaseReference *testReference) {
|
||||||
/*!
|
/*!
|
||||||
* Prints usage information
|
* Prints usage information
|
||||||
*/
|
*/
|
||||||
void printUsage() {
|
void
|
||||||
|
printUsage() {
|
||||||
printf("Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST] [--help]\n");
|
printf("Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST] [--help]\n");
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" --in-proc Executes tests in-process\n");
|
printf(" --in-proc Executes tests in-process\n");
|
||||||
|
@ -344,17 +345,16 @@ SuiteIsSelected(char *testSuiteName) {
|
||||||
char buffer[NAME_BUFFER_SIZE];
|
char buffer[NAME_BUFFER_SIZE];
|
||||||
int len = strlen(testSuiteName);
|
int len = strlen(testSuiteName);
|
||||||
|
|
||||||
//! \todo Fix this, it's rather horrible way to do it
|
const int dirNameLength = 6;
|
||||||
#define DIR_NAME_LENGTH 6
|
|
||||||
#if defined(linux) || defined( __linux)
|
#if defined(linux) || defined( __linux)
|
||||||
#define FILE_EXT_LENGTH 3
|
const int fileExtLength = 3;
|
||||||
#else
|
#else
|
||||||
#define FILE_EXT_LENGTH 6
|
const int fileExtLength = 6;
|
||||||
#endif
|
#endif
|
||||||
int length = len - DIR_NAME_LENGTH - FILE_EXT_LENGTH;
|
int length = len - dirNameLength - fileExtLength;
|
||||||
|
|
||||||
memset(buffer, 0, NAME_BUFFER_SIZE);
|
memset(buffer, 0, NAME_BUFFER_SIZE);
|
||||||
memcpy(buffer, testSuiteName + DIR_NAME_LENGTH, length);
|
memcpy(buffer, testSuiteName + dirNameLength, length);
|
||||||
|
|
||||||
retVal = SDL_strncmp(selected_suite_name, buffer, NAME_BUFFER_SIZE) == 0;
|
retVal = SDL_strncmp(selected_suite_name, buffer, NAME_BUFFER_SIZE) == 0;
|
||||||
}
|
}
|
||||||
|
@ -377,53 +377,50 @@ main(int argc, char *argv[])
|
||||||
// print: Testing against SDL version fuu (rev: bar) if verbose == true
|
// print: Testing against SDL version fuu (rev: bar) if verbose == true
|
||||||
|
|
||||||
int failureCount = 0, passCount = 0;
|
int failureCount = 0, passCount = 0;
|
||||||
|
|
||||||
const Uint32 startTicks = SDL_GetTicks();
|
|
||||||
|
|
||||||
char **testSuiteNames = ScanForTestSuites();
|
|
||||||
|
|
||||||
char *testSuiteName = NULL;
|
char *testSuiteName = NULL;
|
||||||
int suiteCounter = 0;
|
int suiteCounter = 0;
|
||||||
|
|
||||||
|
const Uint32 startTicks = SDL_GetTicks();
|
||||||
|
char **testSuiteNames = ScanForTestSuites();
|
||||||
|
|
||||||
for(testSuiteName = testSuiteNames[suiteCounter]; testSuiteName; testSuiteName = testSuiteNames[++suiteCounter]) {
|
for(testSuiteName = testSuiteNames[suiteCounter]; testSuiteName; testSuiteName = testSuiteNames[++suiteCounter]) {
|
||||||
// if the current suite isn't selected, go to next suite
|
// if the current suite isn't selected, go to next suite
|
||||||
if(SuiteIsSelected(testSuiteName) == 0) {
|
if(SuiteIsSelected(testSuiteName)) {
|
||||||
continue;
|
void *suite = LoadTestSuite(testSuiteName);
|
||||||
}
|
TestCaseReference **tests = QueryTestCases(suite);
|
||||||
|
|
||||||
void *suite = LoadTestSuite(testSuiteName);
|
TestCaseReference *reference = NULL;
|
||||||
TestCaseReference **tests = QueryTestCases(suite);
|
int counter = 0;
|
||||||
|
for(reference = tests[counter]; reference; reference = tests[++counter]) {
|
||||||
TestCaseReference *reference = NULL;
|
if(only_selected_test && SDL_strncmp(selected_test_name, reference->name, NAME_BUFFER_SIZE) != 0) {
|
||||||
int counter = 0;
|
continue;
|
||||||
for(reference = tests[counter]; reference; reference = tests[++counter]) {
|
|
||||||
if(only_selected_test && SDL_strncmp(selected_test_name, reference->name, NAME_BUFFER_SIZE) != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(reference->enabled == TEST_DISABLED) {
|
|
||||||
printf("Test %s (in %s) disabled. Omitting...\n", reference->name, testSuiteName);
|
|
||||||
} else {
|
|
||||||
printf("Executing %s (in %s):\n", reference->name, testSuiteName);
|
|
||||||
|
|
||||||
int retVal = ExecuteTest(suite, reference);
|
|
||||||
|
|
||||||
if(retVal) {
|
|
||||||
failureCount++;
|
|
||||||
if(retVal == 2) {
|
|
||||||
printf("%s (in %s): FAILED -> No asserts\n", reference->name, testSuiteName);
|
|
||||||
} else {
|
|
||||||
printf("%s (in %s): FAILED\n", reference->name, testSuiteName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
passCount++;
|
|
||||||
printf("%s (in %s): ok\n", reference->name, testSuiteName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(reference->enabled == TEST_DISABLED) {
|
||||||
|
printf("Test %s (in %s) disabled. Omitting...\n", reference->name, testSuiteName);
|
||||||
|
} else {
|
||||||
|
printf("Executing %s (in %s):\n", reference->name, testSuiteName);
|
||||||
|
|
||||||
|
int retVal = ExecuteTest(suite, reference);
|
||||||
|
|
||||||
|
if(retVal) {
|
||||||
|
failureCount++;
|
||||||
|
if(retVal == 2) {
|
||||||
|
printf("%s (in %s): FAILED -> No asserts\n", reference->name, testSuiteName);
|
||||||
|
} else {
|
||||||
|
printf("%s (in %s): FAILED\n", reference->name, testSuiteName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
passCount++;
|
||||||
|
printf("%s (in %s): ok\n", reference->name, testSuiteName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
SDL_UnloadObject(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnloadObject(suite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Uint32 endTicks = SDL_GetTicks();
|
const Uint32 endTicks = SDL_GetTicks();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue