Skip to content

Commit

Permalink
[Author: thomasvl]
Browse files Browse the repository at this point in the history
The iOS 5.0 runtime doesn't seem to sort the class list any more, but
  it used to or we used to just get lucking in some of our testing.
  SenTest sorts the classes, so follow that lead also.

R=dmaclach
DELTA=13  (13 added, 0 deleted, 0 changed)

git-svn-id: http://google-toolbox-for-mac.googlecode.com/svn/trunk@513 7dc7ac4e-7543-0410-b95c-c1676fc8e2a3
  • Loading branch information
gtm.daemon committed Feb 21, 2012
1 parent df0bdc0 commit 9e5d781
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions UnitTesting/GTMIPhoneUnitTestDelegate.m
Expand Up @@ -113,6 +113,14 @@ - (void)runTestsAndExit:(UIApplication *)application {
[self setRetainer:nil];
}

static int ClassSort(const void *a, const void *b) {
Class *classA = (Class *)a;
Class *classB = (Class *)b;
const char *nameA = class_getName(*classA);
const char *nameB = class_getName(*classB);
return strcmp(nameA, nameB);
}

// Run through all the registered classes and run test methods on any
// that are subclasses of SenTestCase. Print results and run time to
// the default output.
Expand All @@ -123,6 +131,11 @@ - (void)runTests {
Class *classes = (Class*)[classData mutableBytes];
_GTMDevAssert(classes, @"Couldn't allocate class list");
objc_getClassList(classes, count);

// Follow SenTest's lead and sort the classes. (This may only be a change
// in the iOS 5 runtime, but make sure it is always sorted just incase)
mergesort(classes, count, sizeof(Class), ClassSort);

totalFailures_ = 0;
totalSuccesses_ = 0;
NSString *suiteName = [[NSBundle mainBundle] bundlePath];
Expand Down

0 comments on commit 9e5d781

Please sign in to comment.