Skip to content

Commit

Permalink
Cedar test bundles emit dots for test runs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffh committed Feb 4, 2014
1 parent 76e965a commit 439157b
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 17 deletions.
16 changes: 16 additions & 0 deletions Cedar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
1FF3591317B6096800096517 /* CDRSymbolicator.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 969B6F95160F1FEC00C7C792 /* CDRSymbolicator.h */; };
1FF4497D18A0B37A00AF94B0 /* AnyArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FF4497C18A0B37A00AF94B0 /* AnyArgument.mm */; };
1FF4497E18A0B37A00AF94B0 /* AnyArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FF4497C18A0B37A00AF94B0 /* AnyArgument.mm */; };
1FF449B118A0C03800AF94B0 /* CDRBufferedDefaultReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF449B018A0C03800AF94B0 /* CDRBufferedDefaultReporter.m */; };
1FF449B218A0C03900AF94B0 /* CDRBufferedDefaultReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FF449B018A0C03800AF94B0 /* CDRBufferedDefaultReporter.m */; };
1FF449B518A0C24400AF94B0 /* CDRBufferedDefaultReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */; };
1FF449B618A0C24600AF94B0 /* CDRBufferedDefaultReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */; };
1FF449B818A0C25C00AF94B0 /* CDRDefaultReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEE1FCB11DC27B800029872 /* CDRDefaultReporter.h */; };
1FF449B918A0C25C00AF94B0 /* CDRExampleReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEE1FD011DC27B800029872 /* CDRExampleReporter.h */; };
2234907D18009DA6001C8E8D /* CDRHooks.h in Headers */ = {isa = PBXBuildFile; fileRef = 2234907C18009DA6001C8E8D /* CDRHooks.h */; settings = {ATTRIBUTES = (Public, ); }; };
2234907F18009DAD001C8E8D /* CDRHooks.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 2234907C18009DA6001C8E8D /* CDRHooks.h */; };
228F3FA717E3ECD10000C8AF /* CDRSpyiOSSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 228F3FA617E3ECD10000C8AF /* CDRSpyiOSSpec.mm */; };
Expand Down Expand Up @@ -597,6 +603,8 @@
1FE15C191869091900207F0C /* CDRReportDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRReportDispatcher.h; sourceTree = "<group>"; };
1FE15C1A1869091900207F0C /* CDRReportDispatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRReportDispatcher.m; sourceTree = "<group>"; };
1FF4497C18A0B37A00AF94B0 /* AnyArgument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnyArgument.mm; sourceTree = "<group>"; };
1FF449B018A0C03800AF94B0 /* CDRBufferedDefaultReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRBufferedDefaultReporter.m; sourceTree = "<group>"; };
1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = CDRBufferedDefaultReporter.h; sourceTree = "<group>"; };
2234907C18009DA6001C8E8D /* CDRHooks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRHooks.h; sourceTree = "<group>"; };
228F3FA617E3ECD10000C8AF /* CDRSpyiOSSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDRSpyiOSSpec.mm; sourceTree = "<group>"; };
22FB7B4016ACBA5900012D69 /* HeadlessSimulatorWorkaround.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeadlessSimulatorWorkaround.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -966,6 +974,7 @@
96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */,
1FE15C1A1869091900207F0C /* CDRReportDispatcher.m */,
42064469139B44F600C85605 /* CDRTeamCityReporter.m */,
1FF449B018A0C03800AF94B0 /* CDRBufferedDefaultReporter.m */,
);
path = Reporters;
sourceTree = "<group>";
Expand All @@ -980,6 +989,7 @@
96EA1CAC142C6449001A78E0 /* CDROTestReporter.h */,
1FE15C191869091900207F0C /* CDRReportDispatcher.h */,
42064465139B44EC00C85605 /* CDRTeamCityReporter.h */,
1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */,
);
path = Reporters;
sourceTree = "<group>";
Expand Down Expand Up @@ -1628,6 +1638,7 @@
AEF32FF8145A2EDF002F93BB /* CompareGreaterThan.h in Headers */,
AEF3300C145B4F75002F93BB /* BeGTE.h in Headers */,
AEF33017145B6222002F93BB /* BeLessThan.h in Headers */,
1FF449B518A0C24400AF94B0 /* CDRBufferedDefaultReporter.h in Headers */,
E31179D2161FD937007D3CDE /* CDRSlowTestStatistics.h in Headers */,
AEF33021145B69DE002F93BB /* BeLTE.h in Headers */,
AE4A945E1880792E008566F5 /* RejectedMethod.h in Headers */,
Expand Down Expand Up @@ -1660,16 +1671,19 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
1FF449B618A0C24600AF94B0 /* CDRBufferedDefaultReporter.h in Headers */,
AEC9DEEF12C2CC7E0039512D /* CDRColorizedReporter.h in Headers */,
42064467139B44EC00C85605 /* CDRTeamCityReporter.h in Headers */,
96EA1CAF142C6449001A78E0 /* CDROTestReporter.h in Headers */,
1FF449B918A0C25C00AF94B0 /* CDRExampleReporter.h in Headers */,
1FE15C1C1869091900207F0C /* CDRReportDispatcher.h in Headers */,
968BA92F143485F800EA40B3 /* CDROTestIPhoneRunner.h in Headers */,
9637852F1491D84F0059C9F6 /* CDROTestHelper.h in Headers */,
492951DE1481AADA00FA8916 /* CDRJUnitXMLReporter.h in Headers */,
AE597B4215B0638B00EEF305 /* InvocationMatcher.h in Headers */,
969B6F97160F1FEC00C7C792 /* CDRSymbolicator.h in Headers */,
E31179D3161FD937007D3CDE /* CDRSlowTestStatistics.h in Headers */,
1FF449B818A0C25C00AF94B0 /* CDRDefaultReporter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2105,6 +2119,7 @@
AEEE1FF711DC27B800029872 /* CDRFunctions.m in Sources */,
AEEE1FF811DC27B800029872 /* CDRSpec.m in Sources */,
AEEE201111DC27B800029872 /* SpecHelper.m in Sources */,
1FF449B118A0C03800AF94B0 /* CDRBufferedDefaultReporter.m in Sources */,
AEFD17BB11DD1E9E00F4448A /* CDRSharedExampleGroupPool.m in Sources */,
AEC9DEEE12C2CC7E0039512D /* CDRColorizedReporter.m in Sources */,
AE8C881413626FE7006C9305 /* CDRSpecFailure.m in Sources */,
Expand Down Expand Up @@ -2235,6 +2250,7 @@
AE36AC6615B5CA6E00EB6C51 /* CedarDouble.mm in Sources */,
AEB1A74315F304A9002E4167 /* StubbedMethod.mm in Sources */,
AE94D04615F3449500A0C2B7 /* AnyInstanceArgument.mm in Sources */,
1FF449B218A0C03900AF94B0 /* CDRBufferedDefaultReporter.m in Sources */,
AE4A946218807DA6008566F5 /* RejectedMethod.mm in Sources */,
AEC7873A15F440980058A27B /* InvocationMatcher.mm in Sources */,
AEC7874E15F444A50058A27B /* HaveReceived.mm in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Source/CDROTestRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void CDRRunTests(id self, SEL _cmd, id ignored) {
// Since we want to have integration with XCode when running tests from inside the IDE
// CDROTestReporter needs to be default reporter; however, we can use any other reporter
// when running from the command line (e.g. CDRColorizedReporter).
NSArray *reporters = CDRReportersFromEnv("CDROTestReporter");
NSArray *reporters = CDRReportersFromEnv("CDROTestReporter,CDRBufferedDefaultReporter");
if (![reporters count]) {
exit(-999);
}
Expand Down
12 changes: 12 additions & 0 deletions Source/Headers/Reporters/CDRBufferedDefaultReporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import "CDRDefaultReporter.h"

@class CDRExample;

@interface CDRBufferedDefaultReporter : CDRDefaultReporter

#pragma mark Overrides
- (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)seed;
- (void)printStats;
- (void)logText:(NSString *)linePartial;

@end
1 change: 1 addition & 0 deletions Source/Headers/Reporters/CDRDefaultReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@

- (void)reportOnExample:(CDRExample *)example;
- (void)printStats;
- (void)logText:(NSString *)linePartial;
@end
30 changes: 30 additions & 0 deletions Source/Reporters/CDRBufferedDefaultReporter.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#import "CDRBufferedDefaultReporter.h"

@interface CDRBufferedDefaultReporter ()
@property (retain, nonatomic) NSMutableString *buffer;
@end

@implementation CDRBufferedDefaultReporter

- (void)dealloc {
self.buffer = nil;
[super dealloc];
}

#pragma mark Overrides
- (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)seed {
self.buffer = [NSMutableString string];
[super runWillStartWithGroups:groups andRandomSeed:seed];
}

- (void)printStats {
[super printStats];

printf("%s", [self.buffer UTF8String]);
}

- (void)logText:(NSString *)linePartial {
[self.buffer appendString:linePartial];
}

@end
37 changes: 22 additions & 15 deletions Source/Reporters/CDRDefaultReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ - (void)runWillStartWithGroups:(NSArray *)groups andRandomSeed:(unsigned int)see
rootGroups_ = [groups retain];
[self startObservingExamples:rootGroups_];
startTime_ = [[NSDate alloc] init];
printf("Running With Random Seed: %i\n\n", seed);
[self logText:[NSString stringWithFormat:@"Running With Random Seed: %i\n\n", seed]];
}

- (void)runDidComplete {
endTime_ = [[NSDate alloc] init];
[self stopObservingExamples:rootGroups_];

printf("\n");
[self logText:@"\n"];
if ([pendingMessages_ count]) {
[self printMessages:pendingMessages_];
}
Expand All @@ -68,6 +68,10 @@ - (int)result {
}

#pragma mark Protected interface
- (void)logText:(NSString *)linePartial {
printf("%s", [linePartial UTF8String]);
}

- (unsigned int)exampleCount {
return exampleCount_;
}
Expand Down Expand Up @@ -123,9 +127,10 @@ - (NSString *)callStackSymbolsForFailure:(CDRSpecFailure *)failure {
if (error.domain == kCDRSymbolicatorErrorDomain) {
if (error.code == kCDRSymbolicatorErrorNotSuccessful) {
NSString *details = [error.userInfo objectForKey:kCDRSymbolicatorErrorMessageKey];
printf("Exception symbolication was not successful.\n"
"To turn it off remove CEDAR_SYMBOLICATE_EXCEPTIONS.\n"
"Details:\n%s\n", details.UTF8String);
[self logText:[NSString stringWithFormat:
@"Exception symbolication was not successful.\n"
@"To turn it off remove CEDAR_SYMBOLICATE_EXCEPTIONS.\n"
@"Details:\n%s\n", details.UTF8String]];
}
}
return callStackSymbols;
Expand All @@ -134,10 +139,10 @@ - (NSString *)callStackSymbolsForFailure:(CDRSpecFailure *)failure {
#pragma mark Private interface

- (void)printMessages:(NSArray *)messages {
printf("\n");
[self logText:@"\n"];

for (NSString *message in messages) {
printf("%s\n", [message cStringUsingEncoding:NSUTF8StringEncoding]);
[self logText:[NSString stringWithFormat:@"%s\n", [message UTF8String]]];
}
}

Expand Down Expand Up @@ -178,7 +183,8 @@ - (void)printNestedFullTextForExample:(CDRExample *)example stateToken:(NSString

if (!onPreviousBranch) {
const char *indicator = (exampleBranchLength - i) == 1 ? [token UTF8String] : " ";
printf("%s %*s%s\n", indicator, 2*i, "", [[exampleBranch objectAtIndex:i] UTF8String]);
[self logText:[NSString stringWithFormat:@"%s %*s%s\n",
indicator, 2*i, "", [[exampleBranch objectAtIndex:i] UTF8String]]];
}
}

Expand Down Expand Up @@ -220,29 +226,30 @@ - (void)reportOnExample:(CDRExample *)example {
if (reporterOpts && strcmp(reporterOpts, "nested") == 0) {
[self printNestedFullTextForExample:example stateToken:stateToken];
} else {
printf("%s", [stateToken cStringUsingEncoding:NSUTF8StringEncoding]);
[self logText:stateToken];
}

if (getenv("CEDAR_REPORT_FAILURES_IMMEDIATELY")) {
if (example.state == CDRExampleStateFailed || example.state == CDRExampleStateError) {
printf("\n%s", [[failureMessages_ lastObject] cStringUsingEncoding:NSUTF8StringEncoding]);
[self logText:[NSString stringWithFormat:@"\n%@", [failureMessages_ lastObject]]];
}
}
}

- (void)printStats {
printf("\nFinished in %.4f seconds\n\n", [endTime_ timeIntervalSinceDate:startTime_]);
printf("%u examples, %u failures", exampleCount_, (unsigned int)failureMessages_.count);
[self logText:[NSString stringWithFormat:@"\nFinished in %.4f seconds\n\n",
[endTime_ timeIntervalSinceDate:startTime_]]];
[self logText:[NSString stringWithFormat:@"%u examples, %u failures", exampleCount_, (unsigned int)failureMessages_.count]];

if (pendingMessages_.count) {
printf(", %u pending", (unsigned int)pendingMessages_.count);
[self logText:[NSString stringWithFormat:@", %u pending", (unsigned int)pendingMessages_.count]];
}

if (skippedMessages_.count) {
printf(", %u skipped", (unsigned int)skippedMessages_.count);
[self logText:[NSString stringWithFormat:@", %u skipped", (unsigned int)skippedMessages_.count]];
}

printf("\n");
[self logText:@"\n"];

if (getenv("CEDAR_REPORT_SLOW_TESTS")) {
CDRSlowTestStatistics *slowTestStats = [[[CDRSlowTestStatistics alloc] init] autorelease];
Expand Down
2 changes: 1 addition & 1 deletion Source/iPhone/CedarApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int runSpecsWithinUIApplication() {

BOOL isTestBundle = objc_getClass("SenTestProbe") || objc_getClass("XCTestProbe");

char *defaultReporterClassName = isTestBundle ? "CDROTestReporter" : "CDRDefaultReporter";
char *defaultReporterClassName = isTestBundle ? "CDROTestReporter,CDRBufferedDefaultReporter" : "CDRDefaultReporter";
@autoreleasepool {
NSArray *reporters = CDRReportersFromEnv(defaultReporterClassName);

Expand Down

0 comments on commit 439157b

Please sign in to comment.