Skip to content

Commit

Permalink
Support selecting specs to run via CEDAR_SPECS env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonah Williams committed Sep 21, 2011
1 parent f16c5b0 commit 8015bea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
19 changes: 18 additions & 1 deletion Source/CDRFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import "CDRExampleReporter.h"
#import "CDRDefaultReporter.h"
#import "SpecHelper.h"
#import "CDRFunctions.h"

BOOL CDRClassIsOfType(Class class, const char * const className) {
if (strcmp(className, class_getName(class))) {
Expand Down Expand Up @@ -103,8 +104,24 @@ int runAllSpecs() {
}

id<CDRExampleReporter> reporter = [[[reporterClass alloc] init] autorelease];
int result = runSpecsWithCustomExampleReporter(NULL, reporter);
int result = runSpecsWithCustomExampleReporter(specClassesToRun(), reporter);
[pool drain];

return result;
}

NSArray *specClassesToRun() {
char *envSpecClassNames = getenv("CEDAR_SPECS");
NSMutableArray *specClassesToRun = nil;
if (envSpecClassNames) {
NSArray *specClassNames = [[NSString stringWithCString:envSpecClassNames encoding:NSUTF8StringEncoding] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
specClassesToRun = [NSMutableArray arrayWithCapacity:[specClassNames count]];
for(NSString *className in specClassNames) {
Class specClass = NSClassFromString(className);
if (specClass) {
[specClassesToRun addObject:specClass];
}
}
}
return [[specClassesToRun copy] autorelease];
}
1 change: 1 addition & 0 deletions Source/Headers/CDRFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
int runSpecsWithCustomExampleReporter(NSArray *specClasses, id<CDRExampleReporter> runner);
int runAllSpecs();
int runAllSpecsWithCustomExampleReporter(id<CDRExampleReporter> runner);
NSArray *specClassesToRun();
4 changes: 3 additions & 1 deletion Source/iPhone/CDRExampleReporterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
}

- (void)startSpecs {
runSpecsWithCustomExampleReporter(NULL, self);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
runSpecsWithCustomExampleReporter(specClassesToRun(), self);
[pool drain];
}

- (void)pushRootSpecStatusController:(NSArray *)groups {
Expand Down

0 comments on commit 8015bea

Please sign in to comment.