From 37ed287f221f2e04d0e0ec89338d632d7920f2c9 Mon Sep 17 00:00:00 2001 From: Tim Jarratt Date: Sat, 13 Jun 2015 13:10:25 -0700 Subject: [PATCH 01/21] Hack together support for XCTest under Xcode7 Leaving the old hacks for Xcode 6 since the XCTestObservation protocol was previously deprecated, behaved differently then, and the observation center had not been introduced then. --- Cedar.xcodeproj/project.pbxproj | 40 ++++++- Source/CDRFunctions.m | 71 +---------- Source/Headers/Project/CDRPrivateFunctions.h | 19 +++ .../Project/XCTest/CDRXCTestObserver.h | 20 ++++ Source/XCTest/CDRXCTestObserver.m | 111 ++++++++++++++++++ 5 files changed, 186 insertions(+), 75 deletions(-) create mode 100644 Source/Headers/Project/CDRPrivateFunctions.h create mode 100644 Source/Headers/Project/XCTest/CDRXCTestObserver.h create mode 100644 Source/XCTest/CDRXCTestObserver.m diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index 9bb73810..c950fe67 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -81,6 +81,10 @@ 34157D101B755E21007AD1BA /* CDRTeamCityReporter.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 42064465139B44EC00C85605 /* CDRTeamCityReporter.h */; }; 34157D111B755E40007AD1BA /* CDRBufferedDefaultReporter.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */; }; 342F5D0B18F430DB00F38E35 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342F5D0A18F430DB00F38E35 /* QuartzCore.framework */; }; + 34322B061BA7405800D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; + 34322B071BA7406100D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; + 34322B091BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; + 34322B0A1BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; 343FAFEA190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 343FAFEB190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 34640DA71B6964F90083EB01 /* CDRBlockHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */; }; @@ -698,6 +702,12 @@ E32861331604F287001FA77E /* FibonacciCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = E32861311604F287001FA77E /* FibonacciCalculator.m */; }; E4BCFDD21817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; E4BCFDD31817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; + F7F409981B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; + F7F4099A1B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; + F7F4099B1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; + F7F4099C1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; + F7F4099D1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; + F7F4099F1B2E3E46001EFA14 /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F4099E1B2E3E26001EFA14 /* CDRPrivateFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -906,6 +916,8 @@ 2234907C18009DA6001C8E8D /* CDRHooks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRHooks.h; sourceTree = ""; }; 228F3FA617E3ECD10000C8AF /* CDRSpyiOSSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = CDRSpyiOSSpec.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 342F5D0A18F430DB00F38E35 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; + 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; + 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestObserver.h; sourceTree = ""; }; 343FAFE8190FDAEC0085AFEC /* DeallocNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeallocNotifier.h; sourceTree = ""; }; 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeallocNotifier.m; sourceTree = ""; }; 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRBlockHelper.h; sourceTree = ""; }; @@ -1192,6 +1204,9 @@ E32861311604F287001FA77E /* FibonacciCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FibonacciCalculator.m; sourceTree = ""; }; E4BCFDD01817FA110083ED98 /* ObjectWithProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectWithProperty.h; sourceTree = ""; }; E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectWithProperty.m; sourceTree = ""; }; + F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestObserver.h; sourceTree = ""; }; + F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestObserver.m; sourceTree = ""; }; + F7F4099E1B2E3E26001EFA14 /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1412,6 +1427,7 @@ 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */, 34F3DF7B1A6ABA2E003041DA /* CDRNil.h */, 96EA1CAD142C6449001A78E0 /* CDROTestRunner.h */, + 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */, AE55BF1D19A7CF83005948E6 /* CDRRuntimeUtilities.h */, 969B6F95160F1FEC00C7C792 /* CDRSymbolicator.h */, 34681C2D18FE4611009D38AC /* CDRTypeUtilities.h */, @@ -1457,8 +1473,9 @@ 34157D181B75A212007AD1BA /* XCTest */ = { isa = PBXGroup; children = ( - AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */, AE34724919C37ECF005CA6F1 /* CDRXCTestCase.h */, + 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */, + AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */, AE4E9B9019C8B44700D794CE /* NSInvocation+CDRXExample.h */, ); path = XCTest; @@ -1679,6 +1696,7 @@ AE0C9D8B19C0C64200B4DD2B /* CDRSpec+XCTestSupport.m */, AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */, AE34724A19C37ECF005CA6F1 /* CDRXCTestCase.m */, + F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */, AE4E9B9119C8B44700D794CE /* NSInvocation+CDRXExample.m */, ); path = XCTest; @@ -2183,6 +2201,7 @@ AE4865A71B0690AF005DB302 /* AnyInstanceArgument.h in Headers */, AE4865A81B0690AF005DB302 /* ReturnValue.h in Headers */, AE4865A91B0690AF005DB302 /* AnyArgument.h in Headers */, + F7F4099A1B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */, AE4865AA1B0690AF005DB302 /* AnyInstanceOfClassArgument.h in Headers */, AE4865AB1B0690AF005DB302 /* AnyInstanceConformingToProtocolArgument.h in Headers */, AE4865AC1B0690AF005DB302 /* CDRProtocolFake.h in Headers */, @@ -2228,6 +2247,7 @@ AE4865D91B0690B1005DB302 /* CDRExampleGroup.h in Headers */, AE4865DA1B0690B1005DB302 /* CDRExampleParent.h in Headers */, AE4865DB1B0690B1005DB302 /* CDRFunctions.h in Headers */, + 34322B0A1BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */, AE4865DC1B0690B1005DB302 /* CDRHooks.h in Headers */, AE4865DD1B0690B1005DB302 /* CDRSharedExampleGroupPool.h in Headers */, AE4865DE1B0690B1005DB302 /* CDRSpec.h in Headers */, @@ -2242,6 +2262,7 @@ AE4865D01B0690B0005DB302 /* ActualValue.h in Headers */, AE4865B41B0690AF005DB302 /* InvocationMatcher.h in Headers */, AE4865E31B0690B2005DB302 /* CDRBlockHelper.h in Headers */, + F7F4099F1B2E3E46001EFA14 /* CDRPrivateFunctions.h in Headers */, AE4865E51B0690B2005DB302 /* CDRNil.h in Headers */, AE48655D1B06769E005DB302 /* CDROTestRunner.h in Headers */, AE4865551B06769D005DB302 /* CDRBufferedDefaultReporter.h in Headers */, @@ -2255,6 +2276,7 @@ AE48651D1B06769B005DB302 /* CDRSpyInfo.h in Headers */, AE4865E81B0691EA005DB302 /* CDRTeamCityReporter.h in Headers */, AE4865691B06769F005DB302 /* CDRXCTestCase.h in Headers */, + 34322B071BA7406100D0CFBD /* CDRPrivateFunctions.h in Headers */, AE4865EC1B069253005DB302 /* CDROTestReporter.h in Headers */, AE4865EA1B069253005DB302 /* CDRExampleReporter.h in Headers */, AE4865531B06769D005DB302 /* CDRReportDispatcher.h in Headers */, @@ -2302,6 +2324,7 @@ AEF8FB0719E6000E00DD4FE4 /* CDRVersion.h in Headers */, 34640DA81B6964FE0083EB01 /* CDRTypeUtilities.h in Headers */, B86B685F1A1326E200F283F7 /* OSXGeometryStringifiers.h in Headers */, + F7F409981B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */, 2234907D18009DA6001C8E8D /* CDRHooks.h in Headers */, AE18A7CF13F453CC00C8872C /* BeTruthy.h in Headers */, AE18A7D013F453CC00C8872C /* Equal.h in Headers */, @@ -2310,6 +2333,7 @@ AE18A7D613F45BFC00C8872C /* ComparatorsContainer.h in Headers */, AE9AA67515AB601500617E1A /* CedarDoubles.h in Headers */, AE9AA67615AB601500617E1A /* CDRSpy.h in Headers */, + 34322B091BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */, AE18A7FB13F4601400C8872C /* Contain.h in Headers */, AE9AA68915AC729800617E1A /* CedarDouble.h in Headers */, AE0F354E19E87D6F00B9F116 /* CompareCloseTo.h in Headers */, @@ -2336,6 +2360,7 @@ 969B6F96160F1FEC00C7C792 /* CDRSymbolicator.h in Headers */, AE84F0DB145B70DD00769F85 /* ShouldSyntax.h in Headers */, 34147770191408C900CBA385 /* AnInstanceOf.h in Headers */, + 34322B061BA7405800D0CFBD /* CDRPrivateFunctions.h in Headers */, AE31A29F19C0F23F00C438C1 /* CDRXTestSuite.h in Headers */, AEB45A911496C8D800845D09 /* RaiseException.h in Headers */, AEC9DEED12C2CC7E0039512D /* CDRColorizedReporter.h in Headers */, @@ -2389,7 +2414,7 @@ name = "Cedar iOS XCTest Tests"; productName = OCUnitAppTests; productReference = 1F45A3DD180E4796003C1E36 /* XCUnitAppTests.xctest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.unit-test"; }; 96A07EEE13F276640021974D /* Cedar OS X FocusedSpecs */ = { isa = PBXNativeTarget; @@ -2443,7 +2468,7 @@ name = "Cedar iOS SenTestingKit Tests"; productName = OCUnitAppTests; productReference = 96B5FA11144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests.octest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.ocunit-test"; }; AE02E7E3184EABCD00414F19 /* Cedar-iOS StaticFrameworkSpecs */ = { isa = PBXNativeTarget; @@ -2516,7 +2541,7 @@ name = "Cedar OS X Host AppTests"; productName = "OS X Host AppTests"; productReference = AE248FAA19DCD52500092C14 /* Cedar OS X Host AppTests.xctest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.unit-test"; }; AE4864F71B067620005DB302 /* Cedar-iOS-Framework */ = { isa = PBXNativeTarget; @@ -2552,7 +2577,7 @@ name = "Cedar OS X Failing Test Bundle"; productName = "OS X Failing Test Bundle"; productReference = AEB8818719DCD62D00F081BA /* Cedar OS X Failing Test Bundle.octest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.ocunit-test"; }; AEEE1FB511DC271300029872 /* Cedar */ = { isa = PBXNativeTarget; @@ -2631,7 +2656,7 @@ AEEE1FA611DC26EA00029872 /* Project object */ = { isa = PBXProject; attributes = { - LastTestingUpgradeCheck = 0610; + LastTestingUpgradeCheck = 0700; LastUpgradeCheck = 0610; ORGANIZATIONNAME = Pivotal; TargetAttributes = { @@ -3062,6 +3087,7 @@ AE48657C1B067953005DB302 /* HaveReceived.mm in Sources */, AE48657D1B067953005DB302 /* CDRSpyInfo.mm in Sources */, AE48657E1B067953005DB302 /* NSInvocation+Cedar.m in Sources */, + F7F4099D1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */, AE48657F1B067953005DB302 /* NSMethodSignature+Cedar.m in Sources */, AE4865801B067953005DB302 /* CDRSpec+XCTestSupport.m in Sources */, AE4865811B067953005DB302 /* CDRXTestSuite.m in Sources */, @@ -3120,6 +3146,7 @@ AEEE1FF611DC27B800029872 /* CDRExampleGroup.m in Sources */, AEEE1FF711DC27B800029872 /* CDRFunctions.m in Sources */, AEEE1FF811DC27B800029872 /* CDRSpec.m in Sources */, + F7F4099B1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */, AEEE201111DC27B800029872 /* CDRSpecHelper.m in Sources */, 1FF449B118A0C03800AF94B0 /* CDRBufferedDefaultReporter.m in Sources */, AEFD17BB11DD1E9E00F4448A /* CDRSharedExampleGroupPool.m in Sources */, @@ -3246,6 +3273,7 @@ 1FF4497E18A0B37A00AF94B0 /* AnyArgument.mm in Sources */, AE4E9B9519C8B44700D794CE /* NSInvocation+CDRXExample.m in Sources */, AE9855AE1236E7080024094E /* CDRSharedExampleGroupPool.m in Sources */, + F7F4099C1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */, AEC9DEF412C2CC8F0039512D /* CDRColorizedReporter.m in Sources */, 1F483E34187D3CD200521F81 /* CDROTestNamer.m in Sources */, 4206446B139B44F600C85605 /* CDRTeamCityReporter.m in Sources */, diff --git a/Source/CDRFunctions.m b/Source/CDRFunctions.m index bb1b2066..1d542c0d 100644 --- a/Source/CDRFunctions.m +++ b/Source/CDRFunctions.m @@ -362,83 +362,16 @@ int CDRRunSpecs() { } } -#pragma mark - Running Test Bundles -#import "CDRXTestSuite.h" -#import "CDRRuntimeUtilities.h" - -@interface CDRXCTestSupport : NSObject -- (id)testSuiteWithName:(NSString *)name; -- (id)defaultTestSuite; -- (id)initWithName:(NSString *)aName; - -- (id)CDR_original_defaultTestSuite; - -- (void)addTest:(id)test; -@end - -static id CDRCreateXCTestSuite() { - Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); - Class testSuiteSubclass = NSClassFromString(@"_CDRXTestSuite"); - - if (testSuiteSubclass == nil) { - size_t size = class_getInstanceSize([CDRXTestSuite class]) - class_getInstanceSize([NSObject class]); - testSuiteSubclass = objc_allocateClassPair(testSuiteClass, "_CDRXTestSuite", size); - CDRCopyClassInternalsFromClass([CDRXTestSuite class], testSuiteSubclass); - objc_registerClassPair(testSuiteSubclass); - } - - id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - unsigned int seed = CDRGetRandomSeed(); - - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - CDRMarkFocusedExamplesInSpecs(specs); - CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); - - CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; - - [testSuite setDispatcher:dispatcher]; - - NSArray *groups = CDRRootGroupsFromSpecs(specs); - [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; - - for (CDRSpec *spec in specs) { - [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; - } - return testSuite; -} - -void CDRInjectIntoXCTestRunner() { - Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); - - if (!testSuiteClass) { - [[NSException exceptionWithName:@"CedarNoTestFrameworkAvailable" reason:@"You must link against either XCTest or SenTestingKit frameworks." userInfo:nil] raise]; - } - - Class testSuiteMetaClass = object_getClass(testSuiteClass); - Method m = class_getClassMethod(testSuiteClass, @selector(defaultTestSuite)); - class_addMethod(testSuiteMetaClass, @selector(CDR_original_defaultTestSuite), method_getImplementation(m), method_getTypeEncoding(m)); - IMP newImp = imp_implementationWithBlock(^id(id self){ - id defaultSuite = [self CDR_original_defaultTestSuite]; - [defaultSuite addTest:CDRCreateXCTestSuite()]; - return defaultSuite; - }); - class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); -} - NSString *CDRGetTestBundleExtension() { NSString *extension = nil;; - NSArray *arguments = [[NSProcessInfo processInfo] arguments]; NSSet *xctestFlags = [NSSet setWithArray:@[@"-XCTest", @"-XCTestScopeFile"]]; if ([xctestFlags intersectsSet:[NSSet setWithArray:arguments]]) { extension = @".xctest"; } else if ([arguments containsObject:@"-SenTest"]) { extension = @".octest"; + } else if ((BOOL)NSClassFromString(@"XCTestCase")) { + extension = @".xctest"; } return extension; diff --git a/Source/Headers/Project/CDRPrivateFunctions.h b/Source/Headers/Project/CDRPrivateFunctions.h new file mode 100644 index 00000000..79a53fa6 --- /dev/null +++ b/Source/Headers/Project/CDRPrivateFunctions.h @@ -0,0 +1,19 @@ +#import + +#ifdef __cplusplus +extern "C" { +#endif + + void CDRMarkXcodeFocusedExamplesInSpecs(NSArray *specs, NSArray *arguments); + void CDRMarkFocusedExamplesInSpecs(NSArray *specs); + NSArray *CDRSpecsFromSpecClasses(NSArray *specClasses); + void CDRDefineSharedExampleGroups(); + void CDRDefineGlobalBeforeAndAfterEachBlocks(); + unsigned int CDRGetRandomSeed(); + NSArray *CDRSpecClassesToRun(); + NSArray *CDRRootGroupsFromSpecs(NSArray *specs); + NSArray *CDRPermuteSpecClassesWithSeed(NSArray *unsortedSpecClasses, unsigned int seed); + +#ifdef __cplusplus +} +#endif diff --git a/Source/Headers/Project/XCTest/CDRXCTestObserver.h b/Source/Headers/Project/XCTest/CDRXCTestObserver.h new file mode 100644 index 00000000..39de5943 --- /dev/null +++ b/Source/Headers/Project/XCTest/CDRXCTestObserver.h @@ -0,0 +1,20 @@ +#import + +@class XCTestSuite; +@protocol XCTestObservation +- (void)testSuiteWillStart:(XCTestSuite *)testSuite; +@end + +@class XCTestObservationCenter; +@interface XCTestObservationCenter +@end + +@interface XCTestObservationCenter (CDRVisibility) ++ (instancetype)sharedTestObservationCenter; +- (void)addTestObserver:(id)observer; +- (void)removeTestObserver:(id)observer; +@end + +@interface CDRXCTestObserver : NSObject + +@end diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m new file mode 100644 index 00000000..1bcf553a --- /dev/null +++ b/Source/XCTest/CDRXCTestObserver.m @@ -0,0 +1,111 @@ +#import "CDRXCTestObserver.h" +#import "CDRFunctions.h" +#import "CDRPrivateFunctions.h" +#import "CDRReportDispatcher.h" +#import "CDRSpec.h" +#import + +#pragma mark - Running Test Bundles +#import "CDRXTestSuite.h" +#import "CDRRuntimeUtilities.h" + +@interface CDRXCTestObserver () +@property (assign) BOOL observedTestSuiteStart; +@end + +@interface CDRXCTestSupport : NSObject +- (id)testSuiteWithName:(NSString *)name; +- (id)defaultTestSuite; +- (id)testSuiteForBundlePath:(NSString *)bundlePath; +- (id)initWithName:(NSString *)aName; + +- (id)CDR_original_defaultTestSuite; + +- (void)addTest:(id)test; +@end + +@implementation CDRXCTestObserver + +- (void)testSuiteWillStart:(XCTestSuite *)testSuite { + if (self.observedTestSuiteStart) { + return; + } + + unsigned int seed = CDRGetRandomSeed(); + NSArray *specClasses = CDRSpecClassesToRun(); + NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); + NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); + CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; + for (CDRSpec *spec in specs) { + [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; + } + + self.observedTestSuiteStart = YES; +} + +@end + +static id CDRCreateXCTestSuite() { + Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); + Class testSuiteSubclass = NSClassFromString(@"_CDRXTestSuite"); + + if (testSuiteSubclass == nil) { + size_t size = class_getInstanceSize([CDRXTestSuite class]) - class_getInstanceSize([NSObject class]); + testSuiteSubclass = objc_allocateClassPair(testSuiteClass, "_CDRXTestSuite", size); + CDRCopyClassInternalsFromClass([CDRXTestSuite class], testSuiteSubclass); + objc_registerClassPair(testSuiteSubclass); + } + + id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; + CDRDefineSharedExampleGroups(); + CDRDefineGlobalBeforeAndAfterEachBlocks(); + + unsigned int seed = CDRGetRandomSeed(); + + NSArray *specClasses = CDRSpecClassesToRun(); + NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); + NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); + CDRMarkFocusedExamplesInSpecs(specs); + CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); + + CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; + + [testSuite setDispatcher:dispatcher]; + + NSArray *groups = CDRRootGroupsFromSpecs(specs); + [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; + + for (CDRSpec *spec in specs) { + [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; + } + return testSuite; +} + +void CDRInjectIntoXCTestRunner() { + // if possible, use the new XCTestObservation protocol + // this is only available starting with iOS 9 and OSX 10.11 + Class observationCenterClass = NSClassFromString(@"XCTestObservationCenter"); + if (observationCenterClass && [observationCenterClass respondsToSelector:@selector(sharedTestObservationCenter)]) { + id observationCenter = [observationCenterClass performSelector:@selector(sharedTestObservationCenter)]; + static CDRXCTestObserver *xcTestObserver; + xcTestObserver = [[CDRXCTestObserver alloc] init]; + [observationCenter addTestObserver:xcTestObserver]; + return; + } + + Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); + if (!testSuiteClass) { + [[NSException exceptionWithName:@"CedarNoTestFrameworkAvailable" reason:@"You must link against either the XCTest or SenTestingKit frameworks." userInfo:nil] raise]; + } + + Class testSuiteMetaClass = object_getClass(testSuiteClass); + Method m = class_getClassMethod(testSuiteClass, @selector(defaultTestSuite)); + + class_addMethod(testSuiteMetaClass, @selector(CDR_original_defaultTestSuite), method_getImplementation(m), method_getTypeEncoding(m)); + IMP newImp = imp_implementationWithBlock(^id(id self){ + id defaultSuite = [self CDR_original_defaultTestSuite]; + [defaultSuite addTest:CDRCreateXCTestSuite()]; + return defaultSuite; + }); + class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); +} From 1954de66fdb2c25d96578099e2f6629ee4f5dd8b Mon Sep 17 00:00:00 2001 From: Tim Jarratt Date: Tue, 30 Jun 2015 22:23:03 -0700 Subject: [PATCH 02/21] Add more specs to XCTest support test bundle Shoutout to @jeffh for catching these. --- Cedar.xcodeproj/project.pbxproj | 22 +++++++++++++++++++ Source/XCTest/CDRXCTestObserver.m | 3 +++ .../XCUnitApplicationTestsWithXCTest.m | 4 ---- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index c950fe67..00157fde 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -702,6 +702,17 @@ E32861331604F287001FA77E /* FibonacciCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = E32861311604F287001FA77E /* FibonacciCalculator.m */; }; E4BCFDD21817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; E4BCFDD31817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; + F78FDA151B43AA8A0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665517315C20003CA143 /* CedarNiceFakeSharedExamples.mm */; }; + F78FDA161B43AA8C0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665517315C20003CA143 /* CedarNiceFakeSharedExamples.mm */; }; + F78FDA171B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665817315DB8003CA143 /* CedarOrdinaryFakeSharedExamples.mm */; }; + F78FDA181B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665817315DB8003CA143 /* CedarOrdinaryFakeSharedExamples.mm */; }; + F78FDA191B43AA930054C768 /* HaveReceivedSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6639A77A14C509FE00B564B7 /* HaveReceivedSpec.mm */; }; + F78FDA1A1B43AA930054C768 /* HaveReceivedSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6639A77A14C509FE00B564B7 /* HaveReceivedSpec.mm */; }; + F78FDA1B1B43AB540054C768 /* SimpleIncrementer.m in Sources */ = {isa = PBXBuildFile; fileRef = AE80788A183C71950078C608 /* SimpleIncrementer.m */; }; + F78FDA1C1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE8C87AB13624524006C9305 /* ExpectFailureWithMessage.mm */; }; + F78FDA1D1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE8C87AB13624524006C9305 /* ExpectFailureWithMessage.mm */; }; + F7A225DC1B43A8FB006231CC /* FooSuperclass.m in Sources */ = {isa = PBXBuildFile; fileRef = AED10EBB18F46C0E00950904 /* FooSuperclass.m */; }; + F7BBE7D31B43A852009547F0 /* CedarDoubleSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE9AA69615ADB99800617E1A /* CedarDoubleSharedExamples.mm */; }; F7F409981B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; F7F4099A1B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; F7F4099B1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; @@ -2896,17 +2907,24 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + F7BBE7D31B43A852009547F0 /* CedarDoubleSharedExamples.mm in Sources */, + F78FDA161B43AA8C0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */, 1F45A3CE180E4796003C1E36 /* OCUnitApplicationTests.mm in Sources */, AE34722A19C118C9005CA6F1 /* SpecSpec.mm in Sources */, + F78FDA181B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */, + F78FDA1D1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */, 1F45A3E3180E4A1C003C1E36 /* XCUnitApplicationTestsWithXCTest.m in Sources */, AE34723019C124CE005CA6F1 /* CDRExampleGroupSpec.mm in Sources */, AE34723719C12534005CA6F1 /* FibonacciCalculator.m in Sources */, AE34722F19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */, + F7A225DC1B43A8FB006231CC /* FooSuperclass.m in Sources */, 1F45A3D0180E4796003C1E36 /* CDRSymbolicatorSpec.mm in Sources */, AE34723919C12588005CA6F1 /* SimpleKeyValueObserver.m in Sources */, + F78FDA1B1B43AB540054C768 /* SimpleIncrementer.m in Sources */, AE34723419C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */, AE34723D19C22547005CA6F1 /* CDRDefaultReporterSpec.mm in Sources */, AE34724619C225A1005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */, + F78FDA1A1B43AA930054C768 /* HaveReceivedSpec.mm in Sources */, AE34722819C11872005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */, 1F45A3D1180E4796003C1E36 /* CDRSpecFailureSpec.mm in Sources */, ); @@ -2942,17 +2960,21 @@ AE34722E19C124CE005CA6F1 /* CDRExampleGroupSpec.mm in Sources */, 9D28051B18E2324300887CC4 /* ObjectWithValueEquality.m in Sources */, AE34722D19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */, + F78FDA191B43AA930054C768 /* HaveReceivedSpec.mm in Sources */, 1FB4F28318891EFE00227772 /* ObjectWithForwardingTarget.m in Sources */, AE52405818F5D604003AB816 /* FooSuperclass.m in Sources */, + F78FDA171B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */, AE34724519C225A0005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */, AE34722919C11876005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */, 1FB4F27D1889195400227772 /* WeakReferenceCompatibilitySpec.mm in Sources */, 1FB4F27F188919A200227772 /* ARCViewController.m in Sources */, + F78FDA151B43AA8A0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */, 1FE2ACB918891FD70000C063 /* CedarDoubleSharedExamples.mm in Sources */, AE34722B19C118CA005CA6F1 /* SpecSpec.mm in Sources */, 1FB4F28218891EF800227772 /* ObjectWithCollections.m in Sources */, 96D34485144A845600352C4A /* OCUnitApplicationTests.mm in Sources */, 1FB4F28518891F0800227772 /* SimpleIncrementer.m in Sources */, + F78FDA1C1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */, 96E807BB1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm in Sources */, 1FB4F27E1889199900227772 /* ObjectWithWeakDelegate.m in Sources */, AE34723319C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */, diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index 1bcf553a..e5f6d27d 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -31,6 +31,9 @@ - (void)testSuiteWillStart:(XCTestSuite *)testSuite { return; } + CDRDefineSharedExampleGroups(); + CDRDefineGlobalBeforeAndAfterEachBlocks(); + unsigned int seed = CDRGetRandomSeed(); NSArray *specClasses = CDRSpecClassesToRun(); NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); diff --git a/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m b/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m index 70b25ce3..b5b845d0 100644 --- a/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m +++ b/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m @@ -24,8 +24,4 @@ - (void)testCanLoadNibFilesFromApp { XCTAssertEqual([[views lastObject] class], [UIView class], @"expected last view of DummyView nib to be UIView kind"); } -- (void)testRunningCedarExamples { - XCTestSuite *defaultSuite = [XCTestSuite defaultTestSuite]; - XCTAssert([[defaultSuite valueForKeyPath:@"tests.name"] containsObject:@"Cedar"]); -} @end From 88cd8fd399564aab1f2b9858bc424bc7e791eca2 Mon Sep 17 00:00:00 2001 From: Elana Koren and Tim Jarratt Date: Tue, 21 Jul 2015 10:34:37 -0700 Subject: [PATCH 03/21] Temporarily change symbolicator so tests pass with xcode 7 beta We should revert / rewrite history before this branch is merged into master. This is purely for our convenience when running tests against the xcode 7 betas. --- Source/CDRSymbolicator.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CDRSymbolicator.m b/Source/CDRSymbolicator.m index 434a1496..24a05acb 100644 --- a/Source/CDRSymbolicator.m +++ b/Source/CDRSymbolicator.m @@ -208,7 +208,7 @@ - (void)launch { [arguments addObject:[NSString stringWithFormat:@"%lx", (long)address.unsignedIntegerValue]]; } - NSString *output = [self.class shellOutWithCommand:@"/Applications/Xcode.app/Contents/Developer/usr/bin/atos" arguments:arguments]; + NSString *output = [self.class shellOutWithCommand:@"/Applications/Xcode-beta.app/Contents/Developer/usr/bin/atos" arguments:arguments]; self.outputLines = [output componentsSeparatedByString:@"\n"]; } From 49b3a62d01a255387a573150bcf4fb311d256b9d Mon Sep 17 00:00:00 2001 From: Elana Koren and Tim Jarratt Date: Tue, 21 Jul 2015 17:15:43 -0700 Subject: [PATCH 04/21] Leave a breadcrumb trail for next person debugging symbolication --- Source/CDRSymbolicator.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CDRSymbolicator.m b/Source/CDRSymbolicator.m index 24a05acb..f3b91776 100644 --- a/Source/CDRSymbolicator.m +++ b/Source/CDRSymbolicator.m @@ -208,6 +208,7 @@ - (void)launch { [arguments addObject:[NSString stringWithFormat:@"%lx", (long)address.unsignedIntegerValue]]; } + // NB: this will almost always fail if the version of Xcode at this location differs from the version used to build the tests NSString *output = [self.class shellOutWithCommand:@"/Applications/Xcode-beta.app/Contents/Developer/usr/bin/atos" arguments:arguments]; self.outputLines = [output componentsSeparatedByString:@"\n"]; } From 3cc7d98ef4cb35e7b8fb8646023edb392ea49e1d Mon Sep 17 00:00:00 2001 From: Elana Koren and Tim Jarratt Date: Tue, 21 Jul 2015 17:55:44 -0700 Subject: [PATCH 05/21] Consolidate test setup between Xcode 6 and 7 --- Source/XCTest/CDRXCTestObserver.m | 65 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index e5f6d27d..33eae395 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -9,8 +9,12 @@ #import "CDRXTestSuite.h" #import "CDRRuntimeUtilities.h" +void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); + @interface CDRXCTestObserver () + @property (assign) BOOL observedTestSuiteStart; + @end @interface CDRXCTestSupport : NSObject @@ -31,17 +35,7 @@ - (void)testSuiteWillStart:(XCTestSuite *)testSuite { return; } - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - unsigned int seed = CDRGetRandomSeed(); - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; - for (CDRSpec *spec in specs) { - [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; - } + CDRAddCedarSpecsToXCTestSuite(testSuite); self.observedTestSuiteStart = YES; } @@ -60,39 +54,21 @@ static id CDRCreateXCTestSuite() { } id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - unsigned int seed = CDRGetRandomSeed(); - - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - CDRMarkFocusedExamplesInSpecs(specs); - CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); - CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; + CDRAddCedarSpecsToXCTestSuite(testSuite); - [testSuite setDispatcher:dispatcher]; - - NSArray *groups = CDRRootGroupsFromSpecs(specs); - [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; - - for (CDRSpec *spec in specs) { - [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; - } return testSuite; } void CDRInjectIntoXCTestRunner() { - // if possible, use the new XCTestObservation protocol - // this is only available starting with iOS 9 and OSX 10.11 + // if possible, use the new XCTestObservation protocol available in Xcode 7 Class observationCenterClass = NSClassFromString(@"XCTestObservationCenter"); if (observationCenterClass && [observationCenterClass respondsToSelector:@selector(sharedTestObservationCenter)]) { - id observationCenter = [observationCenterClass performSelector:@selector(sharedTestObservationCenter)]; + id observationCenter = [observationCenterClass sharedTestObservationCenter]; static CDRXCTestObserver *xcTestObserver; xcTestObserver = [[CDRXCTestObserver alloc] init]; [observationCenter addTestObserver:xcTestObserver]; + return; } @@ -112,3 +88,26 @@ void CDRInjectIntoXCTestRunner() { }); class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); } + +void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { + unsigned int seed = CDRGetRandomSeed(); + + CDRDefineSharedExampleGroups(); + CDRDefineGlobalBeforeAndAfterEachBlocks(); + + NSArray *specClasses = CDRSpecClassesToRun(); + NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); + NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); + + CDRMarkFocusedExamplesInSpecs(specs); + CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); + + CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; + + NSArray *groups = CDRRootGroupsFromSpecs(specs); + [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; + + for (CDRSpec *spec in specs) { + [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; + } +} From 40f9f1b8d0cc5d97fc6b6e7d61ea698a9483c4a1 Mon Sep 17 00:00:00 2001 From: Tim Jarratt Date: Tue, 21 Jul 2015 17:55:59 -0700 Subject: [PATCH 06/21] Don't run SenTestingKit specs on Xcode 7 --- Rakefile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Rakefile b/Rakefile index 64047995..72b37d5d 100644 --- a/Rakefile +++ b/Rakefile @@ -112,6 +112,10 @@ EOF end class Xcode + def self.version + `xcodebuild -version | grep Xcode`.chomp.split(' ').last.to_f + end + def self.developer_dir `xcode-select -print-path`.strip end @@ -477,22 +481,25 @@ namespace :testbundles do ) end - desc "Build and run OCUnit logic and application specs" - task ocunit: ["ocunit:application"] + if Xcode.version < 7.0 + desc "Build and run OCUnit logic and application specs" + task ocunit: ["ocunit:application"] - namespace :ocunit do - desc "Build and run OCUnit application specs (#{OCUNIT_APPLICATION_SPECS_SCHEME_NAME})" - task application: :convert_to_xcode5 do - Simulator.kill + namespace :ocunit do + desc "Build and run OCUnit application specs (#{OCUNIT_APPLICATION_SPECS_SCHEME_NAME})" + task application: :convert_to_xcode5 do + Simulator.kill - Xcode.test( - scheme: OCUNIT_APPLICATION_SPECS_SCHEME_NAME, - sdk: "iphonesimulator#{SDK_VERSION}", - args: "ARCHS=i386 -destination '#{Xcode.destination_for_ios_sdk(SDK_RUNTIME_VERSION)}' -destination-timeout 9", - logfile: "ocunit-application-specs.log", - ) + Xcode.test( + scheme: OCUNIT_APPLICATION_SPECS_SCHEME_NAME, + sdk: "iphonesimulator#{SDK_VERSION}", + args: "ARCHS=i386 -destination '#{Xcode.destination_for_ios_sdk(SDK_RUNTIME_VERSION)}' -destination-timeout 9", + logfile: "ocunit-application-specs.log", + ) + end end end + desc 'A target that does not have XCTest or SenTestingKit linked should alert the user' task :failing_test_bundle do the_exception = nil From e2394703b064031d6a42a7517b6a366aa20e2e8a Mon Sep 17 00:00:00 2001 From: Daniel Shusta and Tim Jarratt Date: Wed, 22 Jul 2015 15:33:47 -0700 Subject: [PATCH 07/21] Just warn when deprecated OCUnit / SentestingKit specs are run This allows us to run the same tasks, regardless of which xcode version is available and currently selected. --- Rakefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 72b37d5d..583e016d 100644 --- a/Rakefile +++ b/Rakefile @@ -481,13 +481,12 @@ namespace :testbundles do ) end - if Xcode.version < 7.0 - desc "Build and run OCUnit logic and application specs" - task ocunit: ["ocunit:application"] - - namespace :ocunit do - desc "Build and run OCUnit application specs (#{OCUNIT_APPLICATION_SPECS_SCHEME_NAME})" - task application: :convert_to_xcode5 do + desc "Build and run OCUnit logic and application specs" + task ocunit: ["ocunit:application"] + namespace :ocunit do + desc "Build and run OCUnit application specs (#{OCUNIT_APPLICATION_SPECS_SCHEME_NAME})" + task application: :convert_to_xcode5 do + if Xcode.version < 7.0 Simulator.kill Xcode.test( @@ -496,6 +495,8 @@ namespace :testbundles do args: "ARCHS=i386 -destination '#{Xcode.destination_for_ios_sdk(SDK_RUNTIME_VERSION)}' -destination-timeout 9", logfile: "ocunit-application-specs.log", ) + else + puts 'Warning :: Cannot test OCUnit support with Xcode 7.' end end end From a55cc04487d40ffbf9322524d6db920978322979 Mon Sep 17 00:00:00 2001 From: Neha Batra and Tim Jarratt Date: Wed, 12 Aug 2015 15:22:30 -0700 Subject: [PATCH 08/21] Use heuristics to avoid selecting the wrong dyld image for symbolication We discovered today that building specs with Xcode 7 introduces a different 0 indexed dyld image compared to previous versions. Starting in Xcode 7 the image is something like /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/dyld_sim (or Xcode-beta) Where in previous versions it would be the path to the application that was going to be run (e.g.: either your specs app, or the production app in the case of test bundles). --- Source/CDRSymbolicator.m | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Source/CDRSymbolicator.m b/Source/CDRSymbolicator.m index f3b91776..d9d78678 100644 --- a/Source/CDRSymbolicator.m +++ b/Source/CDRSymbolicator.m @@ -282,23 +282,33 @@ + (NSString *)shellOutWithCommand:(NSString *)command arguments:(NSArray *)argum @implementation CDRAtosTask (CurrentTestExecutable) + (CDRAtosTask *)taskForCurrentTestExecutable { - NSString *executablePath = [[NSBundle mainBundle] executablePath]; - long slide = _dyld_get_image_vmaddr_slide(0); + uint32_t imageCount = _dyld_image_count(); + BOOL runningWithTestBundle = objc_getClass("SenTestProbe") || objc_getClass("XCTestProbe"); - // If running with SenTestingKit use test bundle executable - if (objc_getClass("SenTestProbe") || objc_getClass("XCTestProbe")) - [self getOtestBundleExecutablePath:&executablePath slide:&slide]; - - return [[[self alloc] initWithExecutablePath:executablePath slide:slide addresses:nil] autorelease]; -} + for (uint32_t imageIndex = 0; imageIndex < imageCount; imageIndex++) { + NSString *imageName = [NSString stringWithCString:_dyld_get_image_name(imageIndex) encoding:NSUTF8StringEncoding]; + if ([imageName hasPrefix: @"/Applications/Xcode"]) { + continue; + } -+ (void)getOtestBundleExecutablePath:(NSString **)executablePath slide:(long *)slide { - for (int i=0; i<_dyld_image_count(); i++) { - if (strstr(_dyld_get_image_name(i), ".octest/") != NULL || strstr(_dyld_get_image_name(i), ".xctest/") != NULL) { - *executablePath = [NSString stringWithUTF8String:_dyld_get_image_name(i)]; - *slide = _dyld_get_image_vmaddr_slide(i); - return; + if (runningWithTestBundle && ![self isImagePathATestBundle:imageName]) { + continue; } + + long slide = _dyld_get_image_vmaddr_slide(imageIndex); + + return [[[self alloc] initWithExecutablePath:imageName + slide:slide + addresses:nil] autorelease]; } + + return nil; +} + ++ (BOOL)isImagePathATestBundle:(NSString *)imageName { + BOOL isOCTestBundle = [imageName containsString:@".octest/"]; + BOOL isXCTestBundle = [imageName containsString:@".xctest/"]; + return isOCTestBundle || isXCTestBundle; } + @end From bf4a38e07ec3c930f218f2ce2aa9ff3fdb758a67 Mon Sep 17 00:00:00 2001 From: Tim Jarratt Date: Thu, 13 Aug 2015 16:44:23 -0700 Subject: [PATCH 09/21] Remove SenTestingKit and OCUnit tests Long live XCTest --- Cedar.xcodeproj/project.pbxproj | 286 +----------------- .../Cedar iOS SenTestingKit Tests.xcscheme | 96 ------ .../OCUnitAppLogicTests-Info.plist | 22 -- .../OCUnitAppLogicTests-Prefix.pch | 7 - OCUnitAppLogicTests/OCUnitAppLogicTests.mm | 14 - .../OCUnitAppLogicTestsWithSenTestingKit.m | 18 -- .../en.lproj/InfoPlist.strings | 2 - ...OCUnitApplicationTestsWithSenTestingKit.mm | 106 ------- Rakefile | 25 +- 9 files changed, 8 insertions(+), 568 deletions(-) delete mode 100644 Cedar.xcodeproj/xcshareddata/xcschemes/Cedar iOS SenTestingKit Tests.xcscheme delete mode 100644 OCUnitAppLogicTests/OCUnitAppLogicTests-Info.plist delete mode 100644 OCUnitAppLogicTests/OCUnitAppLogicTests-Prefix.pch delete mode 100644 OCUnitAppLogicTests/OCUnitAppLogicTests.mm delete mode 100644 OCUnitAppLogicTests/OCUnitAppLogicTestsWithSenTestingKit.m delete mode 100644 OCUnitAppLogicTests/en.lproj/InfoPlist.strings delete mode 100644 OCUnitAppTests/OCUnitApplicationTestsWithSenTestingKit.mm diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index 00157fde..0313f195 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 1F4251DE180E0CB200FC578B /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F4251DC180E0CA200FC578B /* SenTestingKit.framework */; }; 1F45A3CE180E4796003C1E36 /* OCUnitApplicationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96D34483144A845100352C4A /* OCUnitApplicationTests.mm */; }; 1F45A3D0180E4796003C1E36 /* CDRSymbolicatorSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96C95B7D161339160018606B /* CDRSymbolicatorSpec.mm */; }; 1F45A3D1180E4796003C1E36 /* CDRSpecFailureSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */; }; @@ -42,24 +41,12 @@ 1F483E34187D3CD200521F81 /* CDROTestNamer.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F483E31187D39D000521F81 /* CDROTestNamer.m */; }; 1F882AAA180F9B6300533238 /* BeNil_ARCSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F882AA9180F9B6300533238 /* BeNil_ARCSpec.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 1F882AAC180FA8D800533238 /* BeSameInstanceAs_ARCSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F882AAB180FA8D800533238 /* BeSameInstanceAs_ARCSpec.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - 1FB4F27D1889195400227772 /* WeakReferenceCompatibilitySpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE5218D4175979D900A656BC /* WeakReferenceCompatibilitySpec.mm */; }; - 1FB4F27E1889199900227772 /* ObjectWithWeakDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5218D2175979CA00A656BC /* ObjectWithWeakDelegate.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - 1FB4F27F188919A200227772 /* ARCViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AE71E7CB175E958F002A54D5 /* ARCViewController.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - 1FB4F28018891ED400227772 /* CDRSpySpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 66F00B5114C4D97C00146D88 /* CDRSpySpec.mm */; }; - 1FB4F28118891EF200227772 /* ArgumentReleaser.m in Sources */ = {isa = PBXBuildFile; fileRef = AE807888183C71950078C608 /* ArgumentReleaser.m */; }; - 1FB4F28218891EF800227772 /* ObjectWithCollections.m in Sources */ = {isa = PBXBuildFile; fileRef = AE3E8F36184FEEE000633740 /* ObjectWithCollections.m */; }; - 1FB4F28318891EFE00227772 /* ObjectWithForwardingTarget.m in Sources */ = {isa = PBXBuildFile; fileRef = AE06D87F17AEEE230084D27C /* ObjectWithForwardingTarget.m */; }; - 1FB4F28418891F0400227772 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; - 1FB4F28518891F0800227772 /* SimpleIncrementer.m in Sources */ = {isa = PBXBuildFile; fileRef = AE80788A183C71950078C608 /* SimpleIncrementer.m */; }; - 1FB4F28618891F0D00227772 /* SimpleKeyValueObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = AE80788C183C71950078C608 /* SimpleKeyValueObserver.m */; }; 1FC90AA819FA2AF50082F844 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96B5F9FB144A81A7000A6A5D /* CoreGraphics.framework */; }; 1FDCD5601821D3BB00B511DB /* BeNil_ARCSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F882AA9180F9B6300533238 /* BeNil_ARCSpec.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 1FDCD5611821D3BF00B511DB /* BeSameInstanceAs_ARCSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F882AAB180FA8D800533238 /* BeSameInstanceAs_ARCSpec.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 1FE15C1B1869091900207F0C /* CDRReportDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FE15C191869091900207F0C /* CDRReportDispatcher.h */; }; 1FE15C1D1869091900207F0C /* CDRReportDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FE15C1A1869091900207F0C /* CDRReportDispatcher.m */; }; 1FE15C201869091900207F0C /* CDRReportDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FE15C1A1869091900207F0C /* CDRReportDispatcher.m */; }; - 1FE2ACB918891FD70000C063 /* CedarDoubleSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE9AA69615ADB99800617E1A /* CedarDoubleSharedExamples.mm */; }; - 1FE2ACBA18891FE90000C063 /* CedarDoubleARCSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE0695F217A1885A0053E59A /* CedarDoubleARCSharedExamples.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 1FF3591117B6094A00096517 /* CDRExample.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = AEEE1FCC11DC27B800029872 /* CDRExample.h */; }; 1FF3591217B6094A00096517 /* CDRExampleGroup.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = AEEE1FCE11DC27B800029872 /* CDRExampleGroup.h */; }; 1FF4497D18A0B37A00AF94B0 /* AnyArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FF4497C18A0B37A00AF94B0 /* AnyArgument.mm */; }; @@ -105,7 +92,6 @@ 34ADE41818F23C8E00BD1E99 /* NSMethodSignature+Cedar.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ADE41618F23C8E00BD1E99 /* NSMethodSignature+Cedar.m */; }; 34ADE41918F23E6B00BD1E99 /* NSMethodSignature+Cedar.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ADE41618F23C8E00BD1E99 /* NSMethodSignature+Cedar.m */; }; 34D4B5C318F3AE0400FB2C3B /* UIKitContainSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34D4B5C118F3ADFF00FB2C3B /* UIKitContainSpec.mm */; }; - 34D93AD51911441300200C71 /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 34EBFD0F18FF505F005392AB /* UIKitComparatorsContainer.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 34D4B5C418F3B68900FB2C3B /* UIKitComparatorsContainer.h */; }; 34F3DF7F1A6ABA2E003041DA /* CDRNil.m in Sources */ = {isa = PBXBuildFile; fileRef = 34F3DF7C1A6ABA2E003041DA /* CDRNil.m */; }; 34F3DF801A6ABA2E003041DA /* CDRNil.m in Sources */ = {isa = PBXBuildFile; fileRef = 34F3DF7C1A6ABA2E003041DA /* CDRNil.m */; }; @@ -146,7 +132,6 @@ 9672F0A71615C1C10012ED58 /* CDRSymbolicatorSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96C95B7D161339160018606B /* CDRSymbolicatorSpec.mm */; }; 9672F0A91615C3F40012ED58 /* CDRSpecSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9672F0A81615C3F40012ED58 /* CDRSpecSpec.mm */; }; 9672F0AA1615C3F40012ED58 /* CDRSpecSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9672F0A81615C3F40012ED58 /* CDRSpecSpec.mm */; }; - 968F9582161AC58200A78D36 /* CDRSymbolicatorSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96C95B7D161339160018606B /* CDRSymbolicatorSpec.mm */; }; 969B6F84160C61E000C7C792 /* CDRSymbolicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 969B6F82160C61E000C7C792 /* CDRSymbolicator.m */; }; 969B6F86160C678400C7C792 /* CDRSymbolicator.m in Sources */ = {isa = PBXBuildFile; fileRef = 969B6F82160C61E000C7C792 /* CDRSymbolicator.m */; }; 969B6F96160F1FEC00C7C792 /* CDRSymbolicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 969B6F95160F1FEC00C7C792 /* CDRSymbolicator.h */; }; @@ -154,7 +139,6 @@ 96A07F0B13F276B10021974D /* FocusedSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 96A07F0A13F276B10021974D /* FocusedSpec.m */; }; 96A07F0F13F27F2F0021974D /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96A07F0E13F27F2F0021974D /* main.mm */; }; 96A07F1113F283E40021974D /* FocusedSpec2.m in Sources */ = {isa = PBXBuildFile; fileRef = 96A07F1013F283E40021974D /* FocusedSpec2.m */; }; - 96A805E416D9B29C005F87FA /* CDRSpecFailureSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */; }; 96B5918F1630F5840068EA5E /* ObjCHeadersSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96B5918E1630F5840068EA5E /* ObjCHeadersSpec.mm */; }; 96B591911630F5B10068EA5E /* ObjCHeadersSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96B5918E1630F5840068EA5E /* ObjCHeadersSpec.mm */; }; 96B5F9FC144A81A7000A6A5D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96B5F9FB144A81A7000A6A5D /* CoreGraphics.framework */; }; @@ -162,13 +146,8 @@ 96B5FA05144A81A8000A6A5D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 96B5FA04144A81A8000A6A5D /* main.m */; }; 96B5FA08144A81A8000A6A5D /* OCUnitAppAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 96B5FA07144A81A8000A6A5D /* OCUnitAppAppDelegate.m */; }; 96B5FA0B144A81A8000A6A5D /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96B5FA09144A81A8000A6A5D /* MainWindow.xib */; }; - 96B5FA14144A81A8000A6A5D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96B5F9FB144A81A7000A6A5D /* CoreGraphics.framework */; }; - 96B5FA1C144A81A8000A6A5D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96B5FA1A144A81A8000A6A5D /* InfoPlist.strings */; }; 96C95B7E161339160018606B /* CDRSymbolicatorSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96C95B7D161339160018606B /* CDRSymbolicatorSpec.mm */; }; 96D34482144A82DB00352C4A /* DummyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96D3447F144A82D100352C4A /* DummyView.xib */; }; - 96D34485144A845600352C4A /* OCUnitApplicationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96D34483144A845100352C4A /* OCUnitApplicationTests.mm */; }; - 96D3448A144A85A500352C4A /* libCedar-StaticLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AEEE222911DC2B0600029872 /* libCedar-StaticLib.a */; }; - 96E807BB1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96E807BA1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm */; }; 96EA1CA8142C6425001A78E0 /* CDROTestReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */; }; 96EA1CA9142C6425001A78E0 /* CDROTestReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */; }; 96EA1CAA142C6425001A78E0 /* CDROTestRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */; }; @@ -178,7 +157,6 @@ 96EA1CBB142C6560001A78E0 /* CDRSpecFailureSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */; }; 9D28051918E2321D00887CC4 /* ObjectWithValueEquality.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D28051818E2321D00887CC4 /* ObjectWithValueEquality.m */; }; 9D28051A18E2324200887CC4 /* ObjectWithValueEquality.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D28051818E2321D00887CC4 /* ObjectWithValueEquality.m */; }; - 9D28051B18E2324300887CC4 /* ObjectWithValueEquality.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D28051818E2321D00887CC4 /* ObjectWithValueEquality.m */; }; AE02021917452007009A7915 /* StringifiersBase.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE02021717452006009A7915 /* StringifiersBase.mm */; }; AE02021A17452007009A7915 /* StringifiersBase.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE02021717452006009A7915 /* StringifiersBase.mm */; }; AE02E7E5184EABCD00414F19 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96158A8C144A915E005895CE /* Foundation.framework */; }; @@ -312,21 +290,13 @@ AE31A2A119C0F23F00C438C1 /* CDRXTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */; }; AE31A2A219C0F23F00C438C1 /* CDRXTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */; }; AE34722819C11872005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF011DC27B800029872 /* GlobalBeforeEachSpec.mm */; }; - AE34722919C11876005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF011DC27B800029872 /* GlobalBeforeEachSpec.mm */; }; AE34722A19C118C9005CA6F1 /* SpecSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF111DC27B800029872 /* SpecSpec.mm */; }; - AE34722B19C118CA005CA6F1 /* SpecSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF111DC27B800029872 /* SpecSpec.mm */; }; - AE34722D19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FE911DC27B800029872 /* CDRExampleSpec.mm */; }; - AE34722E19C124CE005CA6F1 /* CDRExampleGroupSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FE811DC27B800029872 /* CDRExampleGroupSpec.mm */; }; AE34722F19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FE911DC27B800029872 /* CDRExampleSpec.mm */; }; AE34723019C124CE005CA6F1 /* CDRExampleGroupSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FE811DC27B800029872 /* CDRExampleGroupSpec.mm */; }; - AE34723319C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96B5918E1630F5840068EA5E /* ObjCHeadersSpec.mm */; }; AE34723419C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96B5918E1630F5840068EA5E /* ObjCHeadersSpec.mm */; }; - AE34723619C12534005CA6F1 /* FibonacciCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = E32861311604F287001FA77E /* FibonacciCalculator.m */; }; AE34723719C12534005CA6F1 /* FibonacciCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = E32861311604F287001FA77E /* FibonacciCalculator.m */; }; AE34723919C12588005CA6F1 /* SimpleKeyValueObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = AE80788C183C71950078C608 /* SimpleKeyValueObserver.m */; }; - AE34723C19C22547005CA6F1 /* CDRDefaultReporterSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEBCDD7E173ACD6700B42B58 /* CDRDefaultReporterSpec.mm */; }; AE34723D19C22547005CA6F1 /* CDRDefaultReporterSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEBCDD7E173ACD6700B42B58 /* CDRDefaultReporterSpec.mm */; }; - AE34724519C225A0005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE34724019C2259B005CA6F1 /* CDRXTestSuiteSpec.mm */; }; AE34724619C225A1005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE34724019C2259B005CA6F1 /* CDRXTestSuiteSpec.mm */; }; AE34724B19C37ECF005CA6F1 /* CDRXCTestCase.h in Headers */ = {isa = PBXBuildFile; fileRef = AE34724919C37ECF005CA6F1 /* CDRXCTestCase.h */; }; AE34724D19C37ECF005CA6F1 /* CDRXCTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = AE34724A19C37ECF005CA6F1 /* CDRXCTestCase.m */; }; @@ -486,7 +456,6 @@ AE4E9B9519C8B44700D794CE /* NSInvocation+CDRXExample.m in Sources */ = {isa = PBXBuildFile; fileRef = AE4E9B9119C8B44700D794CE /* NSInvocation+CDRXExample.m */; }; AE5218D3175979CA00A656BC /* ObjectWithWeakDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AE5218D2175979CA00A656BC /* ObjectWithWeakDelegate.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; AE5218D5175979D900A656BC /* WeakReferenceCompatibilitySpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE5218D4175979D900A656BC /* WeakReferenceCompatibilitySpec.mm */; }; - AE52405818F5D604003AB816 /* FooSuperclass.m in Sources */ = {isa = PBXBuildFile; fileRef = AED10EBB18F46C0E00950904 /* FooSuperclass.m */; }; AE53B67E17E7BCAA00D83D5E /* CDRClassFakeSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE9AA67F15AB748E00617E1A /* CDRClassFakeSpec.mm */; }; AE53B67F17E7BCAA00D83D5E /* CDRProtocolFakeSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE74903015B45E9D008EA127 /* CDRProtocolFakeSpec.mm */; }; AE53B68017E7BCAA00D83D5E /* CDRSpySpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 66F00B5114C4D97C00146D88 /* CDRSpySpec.mm */; }; @@ -568,7 +537,6 @@ AEC40C51174AC4C700474D2D /* UIGeometryStringifiers.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = AEC40C4F174AC4C000474D2D /* UIGeometryStringifiers.h */; }; AEC40C54174AC51D00474D2D /* UIKitEqualSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEC40C53174AC51800474D2D /* UIKitEqualSpec.mm */; }; AEC40C58174ACAD900474D2D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEC40C57174ACAD900474D2D /* UIKit.framework */; }; - AEC40C59174ACAEE00474D2D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEC40C57174ACAD900474D2D /* UIKit.framework */; }; AEC54007185E90D900B0D41D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEC54006185E90D900B0D41D /* UIKit.framework */; }; AEC54009185E90E900B0D41D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEC54008185E90E900B0D41D /* CoreGraphics.framework */; }; AEC7873915F440980058A27B /* InvocationMatcher.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEC7873715F440980058A27B /* InvocationMatcher.mm */; }; @@ -702,14 +670,10 @@ E32861331604F287001FA77E /* FibonacciCalculator.m in Sources */ = {isa = PBXBuildFile; fileRef = E32861311604F287001FA77E /* FibonacciCalculator.m */; }; E4BCFDD21817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; E4BCFDD31817FA110083ED98 /* ObjectWithProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */; }; - F78FDA151B43AA8A0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665517315C20003CA143 /* CedarNiceFakeSharedExamples.mm */; }; F78FDA161B43AA8C0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665517315C20003CA143 /* CedarNiceFakeSharedExamples.mm */; }; - F78FDA171B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665817315DB8003CA143 /* CedarOrdinaryFakeSharedExamples.mm */; }; F78FDA181B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEE0665817315DB8003CA143 /* CedarOrdinaryFakeSharedExamples.mm */; }; - F78FDA191B43AA930054C768 /* HaveReceivedSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6639A77A14C509FE00B564B7 /* HaveReceivedSpec.mm */; }; F78FDA1A1B43AA930054C768 /* HaveReceivedSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6639A77A14C509FE00B564B7 /* HaveReceivedSpec.mm */; }; F78FDA1B1B43AB540054C768 /* SimpleIncrementer.m in Sources */ = {isa = PBXBuildFile; fileRef = AE80788A183C71950078C608 /* SimpleIncrementer.m */; }; - F78FDA1C1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE8C87AB13624524006C9305 /* ExpectFailureWithMessage.mm */; }; F78FDA1D1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE8C87AB13624524006C9305 /* ExpectFailureWithMessage.mm */; }; F7A225DC1B43A8FB006231CC /* FooSuperclass.m in Sources */ = {isa = PBXBuildFile; fileRef = AED10EBB18F46C0E00950904 /* FooSuperclass.m */; }; F7BBE7D31B43A852009547F0 /* CedarDoubleSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE9AA69615ADB99800617E1A /* CedarDoubleSharedExamples.mm */; }; @@ -743,20 +707,6 @@ remoteGlobalIDString = AEEE1FB511DC271300029872; remoteInfo = Cedar; }; - 96B5FA15144A81A8000A6A5D /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = AEEE1FA611DC26EA00029872 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 96B5F9F5144A81A7000A6A5D; - remoteInfo = OCUnitApp; - }; - 96D34486144A859200352C4A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = AEEE1FA611DC26EA00029872 /* Project object */; - proxyType = 1; - remoteGlobalIDString = AEEE222811DC2B0600029872; - remoteInfo = "Cedar-StaticLib"; - }; AE02E80E184EADE100414F19 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = AEEE1FA611DC26EA00029872 /* Project object */; @@ -971,10 +921,6 @@ 96158A8A144A915E005895CE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 96158A8B144A915E005895CE /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 96158A8C144A915E005895CE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 96158A8F144A915E005895CE /* OCUnitAppLogicTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OCUnitAppLogicTests-Info.plist"; sourceTree = ""; }; - 96158A91144A915E005895CE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - 96158A93144A915E005895CE /* OCUnitAppLogicTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OCUnitAppLogicTests-Prefix.pch"; sourceTree = ""; }; - 96158A9E144A91C4005895CE /* OCUnitAppLogicTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCUnitAppLogicTests.mm; sourceTree = ""; }; 96158AA0144A91DC005895CE /* DummyModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DummyModel.h; sourceTree = ""; }; 96158AA1144A91DC005895CE /* DummyModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DummyModel.m; sourceTree = ""; }; 966E74EC145A6CA0002E8D49 /* ShouldSyntaxSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ShouldSyntaxSpec.mm; path = ../ShouldSyntaxSpec.mm; sourceTree = ""; }; @@ -995,15 +941,12 @@ 96B5FA06144A81A8000A6A5D /* OCUnitAppAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCUnitAppAppDelegate.h; sourceTree = ""; }; 96B5FA07144A81A8000A6A5D /* OCUnitAppAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OCUnitAppAppDelegate.m; sourceTree = ""; }; 96B5FA0A144A81A8000A6A5D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; - 96B5FA11144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Cedar iOS SenTestingKit Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; 96B5FA19144A81A8000A6A5D /* OCUnitAppTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OCUnitAppTests-Info.plist"; sourceTree = ""; }; 96B5FA1B144A81A8000A6A5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 96B5FA1D144A81A8000A6A5D /* OCUnitAppTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OCUnitAppTests-Prefix.pch"; sourceTree = ""; }; 96C95B7D161339160018606B /* CDRSymbolicatorSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = CDRSymbolicatorSpec.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 96D34480144A82D100352C4A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DummyView.xib; sourceTree = ""; }; 96D34483144A845100352C4A /* OCUnitApplicationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCUnitApplicationTests.mm; sourceTree = ""; }; - 96E807BA1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCUnitApplicationTestsWithSenTestingKit.mm; sourceTree = ""; }; - 96E807BC1491C6D200388D9D /* OCUnitAppLogicTestsWithSenTestingKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCUnitAppLogicTestsWithSenTestingKit.m; sourceTree = ""; }; 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CDROTestReporter.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDROTestRunner.m; sourceTree = ""; }; 96EA1CAC142C6449001A78E0 /* CDROTestReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDROTestReporter.h; sourceTree = ""; }; @@ -1249,17 +1192,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 96B5FA0D144A81A8000A6A5D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 1F4251DE180E0CB200FC578B /* SenTestingKit.framework in Frameworks */, - AEC40C59174ACAEE00474D2D /* UIKit.framework in Frameworks */, - 96B5FA14144A81A8000A6A5D /* CoreGraphics.framework in Frameworks */, - 96D3448A144A85A500352C4A /* libCedar-StaticLib.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AE02E7E1184EABCD00414F19 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1553,35 +1485,14 @@ path = Doubles; sourceTree = ""; }; - 96158A8D144A915E005895CE /* OCUnitAppLogicTests */ = { - isa = PBXGroup; - children = ( - 96158A9E144A91C4005895CE /* OCUnitAppLogicTests.mm */, - 96E807BC1491C6D200388D9D /* OCUnitAppLogicTestsWithSenTestingKit.m */, - 96158A8E144A915E005895CE /* Supporting Files */, - ); - path = OCUnitAppLogicTests; - sourceTree = ""; - }; - 96158A8E144A915E005895CE /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 96158A8F144A915E005895CE /* OCUnitAppLogicTests-Info.plist */, - 96158A90144A915E005895CE /* InfoPlist.strings */, - 96158A93144A915E005895CE /* OCUnitAppLogicTests-Prefix.pch */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 9668DCDE144A92BA007C7294 /* OCUnit Support */ = { + 9668DCDE144A92BA007C7294 /* Test Bundle Support */ = { isa = PBXGroup; children = ( 1F45A3DF180E47AA003C1E36 /* XCUnitAppTests */, - 96B5F9FD144A81A7000A6A5D /* OCUnitApp */, + 96B5F9FD144A81A7000A6A5D /* Test Bundle App */, 96B5FA17144A81A8000A6A5D /* OCUnitAppTests */, - 96158A8D144A915E005895CE /* OCUnitAppLogicTests */, ); - name = "OCUnit Support"; + name = "Test Bundle Support"; sourceTree = ""; }; 96A07F0D13F27ED70021974D /* Focused */ = { @@ -1594,7 +1505,7 @@ name = Focused; sourceTree = ""; }; - 96B5F9FD144A81A7000A6A5D /* OCUnitApp */ = { + 96B5F9FD144A81A7000A6A5D /* Test Bundle App */ = { isa = PBXGroup; children = ( 96158AA0144A91DC005895CE /* DummyModel.h */, @@ -1605,6 +1516,7 @@ 96D3447F144A82D100352C4A /* DummyView.xib */, 96B5F9FE144A81A7000A6A5D /* Supporting Files */, ); + name = "Test Bundle App"; path = OCUnitApp; sourceTree = ""; }; @@ -1623,7 +1535,6 @@ isa = PBXGroup; children = ( 96D34483144A845100352C4A /* OCUnitApplicationTests.mm */, - 96E807BA1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm */, 96B5FA18144A81A8000A6A5D /* Supporting Files */, ); path = OCUnitAppTests; @@ -1913,7 +1824,7 @@ children = ( AEEE1FC311DC27B800029872 /* Source */, AEEE1FE711DC27B800029872 /* Spec */, - 9668DCDE144A92BA007C7294 /* OCUnit Support */, + 9668DCDE144A92BA007C7294 /* Test Bundle Support */, AE248F9919DCD52500092C14 /* OS X Host App */, AE248FAD19DCD52500092C14 /* OS X Host AppTests */, AEB8818919DCD62D00F081BA /* OS X Failing Test Bundle */, @@ -1937,7 +1848,6 @@ AEEE227611DC2CF900029872 /* Cedar-StaticLib Specs.app */, 96A07F0813F276640021974D /* Cedar OS X FocusedSpecs */, 96B5F9F6144A81A7000A6A5D /* Cedar iOS Host App.app */, - 96B5FA11144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests.octest */, 1F45A3DD180E4796003C1E36 /* XCUnitAppTests.xctest */, AE02E7E4184EABCD00414F19 /* Cedar-iOS StaticFrameworkSpecs.app */, AE248F9819DCD52500092C14 /* Cedar OS X Host App.app */, @@ -2461,26 +2371,6 @@ productReference = 96B5F9F6144A81A7000A6A5D /* Cedar iOS Host App.app */; productType = "com.apple.product-type.application"; }; - 96B5FA10144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 96B5FA25144A81A8000A6A5D /* Build configuration list for PBXNativeTarget "Cedar iOS SenTestingKit Tests" */; - buildPhases = ( - 96B5FA0C144A81A8000A6A5D /* Sources */, - 96B5FA0D144A81A8000A6A5D /* Frameworks */, - 96B5FA0E144A81A8000A6A5D /* Resources */, - 96B5FA0F144A81A8000A6A5D /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 96D34487144A859200352C4A /* PBXTargetDependency */, - 96B5FA16144A81A8000A6A5D /* PBXTargetDependency */, - ); - name = "Cedar iOS SenTestingKit Tests"; - productName = OCUnitAppTests; - productReference = 96B5FA11144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests.octest */; - productType = "com.apple.product-type.bundle.ocunit-test"; - }; AE02E7E3184EABCD00414F19 /* Cedar-iOS StaticFrameworkSpecs */ = { isa = PBXNativeTarget; buildConfigurationList = AE02E808184EABCE00414F19 /* Build configuration list for PBXNativeTarget "Cedar-iOS StaticFrameworkSpecs" */; @@ -2714,7 +2604,6 @@ AEEE227511DC2CF900029872 /* Cedar-StaticLib Specs */, AE02E7E3184EABCD00414F19 /* Cedar-iOS StaticFrameworkSpecs */, 96B5F9F5144A81A7000A6A5D /* Cedar iOS Host App */, - 96B5FA10144A81A8000A6A5D /* Cedar iOS SenTestingKit Tests */, 1F45A3C8180E4796003C1E36 /* Cedar iOS XCTest Tests */, AE248F9719DCD52500092C14 /* Cedar OS X Host App */, AE248FA919DCD52500092C14 /* Cedar OS X Host AppTests */, @@ -2744,14 +2633,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 96B5FA0E144A81A8000A6A5D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 96B5FA1C144A81A8000A6A5D /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AE02E7E2184EABCD00414F19 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -2859,19 +2740,6 @@ shellPath = "/usr/bin/env ruby"; shellScript = "key = \"CDRBuildVersionSHA\"\nver = `git rev-parse HEAD`.strip\nputs \"Git commit SHA is #{ver}\"\npath = \"#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['INFOPLIST_PATH']}\"\nputs \"Updating #{path}\"\n`/usr/libexec/PlistBuddy -c \"Add :#{key} string #{ver}\" \"#{path}\"`"; }; - 96B5FA0F144A81A8000A6A5D /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; AEEE225511DC2BD700029872 /* Build architecture-specific static libs */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -2953,44 +2821,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 96B5FA0C144A81A8000A6A5D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AE34722E19C124CE005CA6F1 /* CDRExampleGroupSpec.mm in Sources */, - 9D28051B18E2324300887CC4 /* ObjectWithValueEquality.m in Sources */, - AE34722D19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */, - F78FDA191B43AA930054C768 /* HaveReceivedSpec.mm in Sources */, - 1FB4F28318891EFE00227772 /* ObjectWithForwardingTarget.m in Sources */, - AE52405818F5D604003AB816 /* FooSuperclass.m in Sources */, - F78FDA171B43AA8F0054C768 /* CedarOrdinaryFakeSharedExamples.mm in Sources */, - AE34724519C225A0005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */, - AE34722919C11876005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */, - 1FB4F27D1889195400227772 /* WeakReferenceCompatibilitySpec.mm in Sources */, - 1FB4F27F188919A200227772 /* ARCViewController.m in Sources */, - F78FDA151B43AA8A0054C768 /* CedarNiceFakeSharedExamples.mm in Sources */, - 1FE2ACB918891FD70000C063 /* CedarDoubleSharedExamples.mm in Sources */, - AE34722B19C118CA005CA6F1 /* SpecSpec.mm in Sources */, - 1FB4F28218891EF800227772 /* ObjectWithCollections.m in Sources */, - 96D34485144A845600352C4A /* OCUnitApplicationTests.mm in Sources */, - 1FB4F28518891F0800227772 /* SimpleIncrementer.m in Sources */, - F78FDA1C1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */, - 96E807BB1491BC7500388D9D /* OCUnitApplicationTestsWithSenTestingKit.mm in Sources */, - 1FB4F27E1889199900227772 /* ObjectWithWeakDelegate.m in Sources */, - AE34723319C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */, - 1FB4F28418891F0400227772 /* ObjectWithProperty.m in Sources */, - 1FB4F28118891EF200227772 /* ArgumentReleaser.m in Sources */, - 1FB4F28018891ED400227772 /* CDRSpySpec.mm in Sources */, - AE34723C19C22547005CA6F1 /* CDRDefaultReporterSpec.mm in Sources */, - AE34723619C12534005CA6F1 /* FibonacciCalculator.m in Sources */, - 1FB4F28618891F0D00227772 /* SimpleKeyValueObserver.m in Sources */, - 1FE2ACBA18891FE90000C063 /* CedarDoubleARCSharedExamples.mm in Sources */, - 968F9582161AC58200A78D36 /* CDRSymbolicatorSpec.mm in Sources */, - 96A805E416D9B29C005F87FA /* CDRSpecFailureSpec.mm in Sources */, - 34D93AD51911441300200C71 /* DeallocNotifier.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AE02E7E0184EABCD00414F19 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3421,16 +3251,6 @@ target = AEEE1FB511DC271300029872 /* Cedar */; targetProxy = 96A07EF013F276640021974D /* PBXContainerItemProxy */; }; - 96B5FA16144A81A8000A6A5D /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 96B5F9F5144A81A7000A6A5D /* Cedar iOS Host App */; - targetProxy = 96B5FA15144A81A8000A6A5D /* PBXContainerItemProxy */; - }; - 96D34487144A859200352C4A /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = AEEE222811DC2B0600029872 /* Cedar-StaticLib */; - targetProxy = 96D34486144A859200352C4A /* PBXContainerItemProxy */; - }; AE02E80F184EADE100414F19 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = AEEE224B11DC2BBB00029872 /* Cedar-iOS StaticFramework */; @@ -3469,14 +3289,6 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 96158A90144A915E005895CE /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 96158A91144A915E005895CE /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; 96B5FA00144A81A8000A6A5D /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( @@ -3706,83 +3518,6 @@ }; name = Release; }; - 96B5FA26144A81A8000A6A5D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Cedar iOS Host App.app/Cedar iOS Host App"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(DEVELOPER_LIBRARY_DIR)/Frameworks", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OCUnitAppTests/OCUnitAppTests-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = DEBUG; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)\"/Source/Matchers/UIKit", - ); - INFOPLIST_FILE = "OCUnitAppTests/OCUnitAppTests-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)\"", - ); - OTHER_LDFLAGS = ( - "-lstdc++", - "-all_load", - "-ObjC", - "-framework", - Foundation, - "-framework", - SenTestingKit, - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphonesimulator; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 96B5FA27144A81A8000A6A5D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Cedar iOS Host App.app/Cedar iOS Host App"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(DEVELOPER_LIBRARY_DIR)/Frameworks", - "$(DEVELOPER_FRAMEWORKS_DIR)", - ); - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OCUnitAppTests/OCUnitAppTests-Prefix.pch"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)\"/Source/Matchers/UIKit", - ); - INFOPLIST_FILE = "OCUnitAppTests/OCUnitAppTests-Info.plist"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "\"$(SRCROOT)\"", - ); - OTHER_LDFLAGS = ( - "-lstdc++", - "-all_load", - "-ObjC", - "-framework", - Foundation, - "-framework", - SenTestingKit, - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphonesimulator; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Release; - }; AE02E809184EABCE00414F19 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4597,15 +4332,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 96B5FA25144A81A8000A6A5D /* Build configuration list for PBXNativeTarget "Cedar iOS SenTestingKit Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 96B5FA26144A81A8000A6A5D /* Debug */, - 96B5FA27144A81A8000A6A5D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; AE02E808184EABCE00414F19 /* Build configuration list for PBXNativeTarget "Cedar-iOS StaticFrameworkSpecs" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar iOS SenTestingKit Tests.xcscheme b/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar iOS SenTestingKit Tests.xcscheme deleted file mode 100644 index 36f1720c..00000000 --- a/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar iOS SenTestingKit Tests.xcscheme +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OCUnitAppLogicTests/OCUnitAppLogicTests-Info.plist b/OCUnitAppLogicTests/OCUnitAppLogicTests-Info.plist deleted file mode 100644 index 32c7be7b..00000000 --- a/OCUnitAppLogicTests/OCUnitAppLogicTests-Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.tomato.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/OCUnitAppLogicTests/OCUnitAppLogicTests-Prefix.pch b/OCUnitAppLogicTests/OCUnitAppLogicTests-Prefix.pch deleted file mode 100644 index ceae4ffb..00000000 --- a/OCUnitAppLogicTests/OCUnitAppLogicTests-Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'OCUnitAppLogicTests' target in the 'OCUnitAppLogicTests' project -// - -#ifdef __OBJC__ - #import -#endif diff --git a/OCUnitAppLogicTests/OCUnitAppLogicTests.mm b/OCUnitAppLogicTests/OCUnitAppLogicTests.mm deleted file mode 100644 index c1c8f099..00000000 --- a/OCUnitAppLogicTests/OCUnitAppLogicTests.mm +++ /dev/null @@ -1,14 +0,0 @@ -#import "CDRSpecHelper.h" -#import "DummyModel.h" // should be included in OCUnitAppLogicTests target - -using namespace Cedar::Matchers; - -SPEC_BEGIN(OCUnitAppLogicTests) - -describe(@"A spec file testing domain classes", ^{ - it(@"should run", ^{ - expect([DummyModel class]).to(equal([DummyModel class])); - }); -}); - -SPEC_END diff --git a/OCUnitAppLogicTests/OCUnitAppLogicTestsWithSenTestingKit.m b/OCUnitAppLogicTests/OCUnitAppLogicTestsWithSenTestingKit.m deleted file mode 100644 index 3ae1a658..00000000 --- a/OCUnitAppLogicTests/OCUnitAppLogicTestsWithSenTestingKit.m +++ /dev/null @@ -1,18 +0,0 @@ -#ifdef USE_XCTEST -#import -#else -#define SENTEST_IGNORE_DEPRECATION_WARNING -#import -#endif - -#import "DummyModel.h" // should be included in OCUnitAppLogicTests target - -@interface ExampleLogicTestsWithSenTestingKit : SenTestCase -@end - -@implementation ExampleLogicTestsWithSenTestingKit -- (void)testLogicTestsRun { - STAssertEquals([DummyModel class], [DummyModel class], @"expected DummyModel class to equal itself"); -} -@end - diff --git a/OCUnitAppLogicTests/en.lproj/InfoPlist.strings b/OCUnitAppLogicTests/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff..00000000 --- a/OCUnitAppLogicTests/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/OCUnitAppTests/OCUnitApplicationTestsWithSenTestingKit.mm b/OCUnitAppTests/OCUnitApplicationTestsWithSenTestingKit.mm deleted file mode 100644 index 5fab8111..00000000 --- a/OCUnitAppTests/OCUnitApplicationTestsWithSenTestingKit.mm +++ /dev/null @@ -1,106 +0,0 @@ -#define SENTEST_IGNORE_DEPRECATION_WARNING -#import -#import "OCUnitAppAppDelegate.h" // should NOT be included in OCUnitAppTests target -#import "CDRXTestSuite.h" -#import "Cedar.h" - -using namespace Cedar::Matchers; - -static BOOL shouldFail = NO; - -#pragma mark - TestObserver -@interface CDRSenTestObserver : SenTestCaseRun -@property (retain, nonatomic) NSException *lastException; -@end - -@implementation CDRSenTestObserver - -- (void)dealloc { - self.lastException = nil; - [super dealloc]; -} - -- (void)addException:(NSException *)anException { - self.lastException = anException; -} - -- (void)postNotificationName:(NSString *)aNotification userInfo:(NSDictionary *)aUserInfo {} -- (void)postNotificationName:(NSString *)aNotification {} - -@end - -#pragma mark - SenTestingKit specs -@interface ExampleApplicationTestsWithSenTestingKit : SenTestCase -@end - -@implementation ExampleApplicationTestsWithSenTestingKit - -- (void)tearDown { - shouldFail = NO; -} - -- (void)testApplicationTestsRun { - UILabel *label = [[[UILabel alloc] init] autorelease]; - STAssertEquals([label class], [UILabel class], @"expected an instance of UILabel to be UILabel kind"); -} - -- (void)testHasAccessToClassesDefinedInApp { - // For that to work app target must have 'Strip Debug Symbols During Copy' set to NO. - STAssertEquals([OCUnitAppAppDelegate class], [OCUnitAppAppDelegate class], @"expected OCUnitAppAppDelegate class to equal itself"); -} - -- (void)testMainBundleIsTheAppBundle { - STAssertTrue([[NSBundle mainBundle].bundlePath hasSuffix:@".app"], @"expected main NSBundle path to have 'app' extension"); -} - -- (void)testCanLoadNibFilesFromApp { - NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"DummyView" owner:nil options:nil]; - STAssertEquals([[views lastObject] class], [UIView class], @"expected last view of DummyView nib to be UIView kind"); -} - -- (void)testRunningCedarExamples { - SenTestSuite *defaultSuite = [SenTestSuite defaultTestSuite]; - STAssertTrue([[defaultSuite valueForKeyPath:@"tests.name"] containsObject:@"Cedar"], @"should contain a Cedar test suite"); -} - -- (void)testCallingDefaultTestSuiteMultipleTimesShouldHaveDifferentReporters { - SenTestSuite *defaultSuite1 = [SenTestSuite defaultTestSuite]; - SenTestSuite *defaultSuite2 = [SenTestSuite defaultTestSuite]; - - CDRXTestSuite *suite1 = [[defaultSuite1 valueForKey:@"tests"] lastObject]; - CDRXTestSuite *suite2 = [[defaultSuite2 valueForKey:@"tests"] lastObject]; - STAssertTrue(suite1.dispatcher != suite2.dispatcher, @"Each test suite should have its own dispatcher"); -} - -- (void)testFailingInATestSuiteProperlyRaisesASenTestingKitException { - CDRXTestSuite *suite = [[[SenTestSuite defaultTestSuite] valueForKey:@"tests"] lastObject]; - NSInteger index = [[suite valueForKeyPath:@"tests.name"] indexOfObject:@"SimulatedTestSuiteFailureSpec"]; - STAssertTrue(index != NSNotFound, @"Failed to find the SimulatedTestSuiteFailureSpec"); - - CDRSenTestObserver *observer = [[[CDRSenTestObserver alloc] init] autorelease]; - - shouldFail = YES; - SenTestCase *testCase = [[[[suite valueForKeyPath:@"tests"] objectAtIndex:index] valueForKey:@"tests"] objectAtIndex:0]; - [testCase performTest:observer]; - - STAssertNotNil(observer.lastException, @"Expected exception to be thrown"); - STAssertEqualObjects(observer.lastException.name, SenTestFailureException, @"Expected %@, but got %@", SenTestFailureException, observer.lastException.name); - NSString *expectedFilename = [NSString stringWithUTF8String:__FILE__]; - STAssertEqualObjects([observer.lastException filename], expectedFilename, @"Expected %@, but got %@", expectedFilename, [observer.lastException filename]); -} - -@end - -#pragma mark - failing cedar spec - -SPEC_BEGIN(SimulatedTestSuiteFailureSpec) - -describe(@"SimulatedTestSuiteFailureSpec", ^{ - it(@"should fail when told to", ^{ - if (shouldFail) { - 1 should equal(2); - } - }); -}); - -SPEC_END diff --git a/Rakefile b/Rakefile index 583e016d..9aa76129 100644 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,6 @@ FOCUSED_SPECS_TARGET_NAME = "Cedar OS X FocusedSpecs" IOS_STATIC_FRAMEWORK_SPECS_TARGET_NAME = "Cedar-iOS StaticFrameworkSpecs" IOS_DYNAMIC_FRAMEWORK_SPECS_TARGET_NAME = "Cedar-iOS-Framework Specs" -OCUNIT_APPLICATION_SPECS_SCHEME_NAME = "Cedar iOS SenTestingKit Tests" XCUNIT_APPLICATION_SPECS_SCHEME_NAME = "Cedar iOS XCTest Tests" OSX_FAILING_SPEC_SCHEME_NAME = "Cedar OS X Failing Test Bundle" @@ -461,8 +460,8 @@ namespace :frameworks do end namespace :testbundles do - desc "Runs all test bundle test suites (xcunit, ocunit:application)" - task run: ['testbundles:xcunit', 'testbundles:ocunit', 'testbundles:failing_test_bundle'] + desc "Runs all test bundle test suites (xcunit)" + task run: ['testbundles:xcunit', 'testbundles:failing_test_bundle'] desc "Converts the test bundle identifier to ones Xcode 5- recognizes (Xcode 6 postfixes the original bundler identifier)" task :convert_to_xcode5 do @@ -481,26 +480,6 @@ namespace :testbundles do ) end - desc "Build and run OCUnit logic and application specs" - task ocunit: ["ocunit:application"] - namespace :ocunit do - desc "Build and run OCUnit application specs (#{OCUNIT_APPLICATION_SPECS_SCHEME_NAME})" - task application: :convert_to_xcode5 do - if Xcode.version < 7.0 - Simulator.kill - - Xcode.test( - scheme: OCUNIT_APPLICATION_SPECS_SCHEME_NAME, - sdk: "iphonesimulator#{SDK_VERSION}", - args: "ARCHS=i386 -destination '#{Xcode.destination_for_ios_sdk(SDK_RUNTIME_VERSION)}' -destination-timeout 9", - logfile: "ocunit-application-specs.log", - ) - else - puts 'Warning :: Cannot test OCUnit support with Xcode 7.' - end - end - end - desc 'A target that does not have XCTest or SenTestingKit linked should alert the user' task :failing_test_bundle do the_exception = nil From e86a08bb8721acd16121b002fea54cd8042dea22 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 31 Aug 2015 21:20:11 -0400 Subject: [PATCH 10/21] Call -runDidComplete on the reporter dispatcher when running a test bundle in Xcode 7 --- .../Project/XCTest/CDRXCTestObserver.h | 1 + Source/XCTest/CDRXCTestObserver.m | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/Headers/Project/XCTest/CDRXCTestObserver.h b/Source/Headers/Project/XCTest/CDRXCTestObserver.h index 39de5943..2c210438 100644 --- a/Source/Headers/Project/XCTest/CDRXCTestObserver.h +++ b/Source/Headers/Project/XCTest/CDRXCTestObserver.h @@ -2,6 +2,7 @@ @class XCTestSuite; @protocol XCTestObservation +- (void)testBundleDidFinish:(NSBundle *)testBundle; - (void)testSuiteWillStart:(XCTestSuite *)testSuite; @end diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index 33eae395..8f518a7d 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -9,10 +9,11 @@ #import "CDRXTestSuite.h" #import "CDRRuntimeUtilities.h" -void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); +CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); @interface CDRXCTestObserver () +@property (retain) CDRReportDispatcher *dispatcher; @property (assign) BOOL observedTestSuiteStart; @end @@ -34,10 +35,18 @@ - (void)testSuiteWillStart:(XCTestSuite *)testSuite { if (self.observedTestSuiteStart) { return; } + self.observedTestSuiteStart = YES; - CDRAddCedarSpecsToXCTestSuite(testSuite); + self.dispatcher = CDRAddCedarSpecsToXCTestSuite(testSuite); +} - self.observedTestSuiteStart = YES; +- (void)testBundleDidFinish:(NSBundle *)testBundle { + [self.dispatcher runDidComplete]; +} + +- (void)dealloc { + self.dispatcher = nil; + [super dealloc]; } @end @@ -89,7 +98,7 @@ void CDRInjectIntoXCTestRunner() { class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); } -void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { +CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { unsigned int seed = CDRGetRandomSeed(); CDRDefineSharedExampleGroups(); @@ -110,4 +119,6 @@ void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { for (CDRSpec *spec in specs) { [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; } + + return dispatcher; } From b2151cc0cfe2dbbeec6bd52d39f46b5501c9d855 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Thu, 3 Sep 2015 23:33:04 -0400 Subject: [PATCH 11/21] Fix regression causing the reporters to not output on Xcode 6 --- Source/XCTest/CDRXCTestObserver.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index 8f518a7d..02219247 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -120,5 +120,9 @@ void CDRInjectIntoXCTestRunner() { [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; } + if ([testSuite respondsToSelector:@selector(setDispatcher:)]) { + [testSuite setDispatcher:dispatcher]; + } + return dispatcher; } From 6c48bfc3b0e1315000804a3525242b8f419745ec Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Fri, 11 Sep 2015 23:19:53 -0400 Subject: [PATCH 12/21] Determine the atos path for symbolication based on compile-time DEVELOPER_DIR --- Cedar.xcodeproj/project.pbxproj | 2 ++ Source/CDRSymbolicator.m | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index 0313f195..b7e6e384 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -3995,6 +3995,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; ONLY_ACTIVE_ARCH = YES; + OTHER_CFLAGS = "-DDEVELOPER_BIN_DIR=@\\\"${DEVELOPER_BIN_DIR}\\\""; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", "-fobjc-call-cxx-cdtors", @@ -4027,6 +4028,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; + OTHER_CFLAGS = "-DDEVELOPER_BIN_DIR=@\\\"${DEVELOPER_BIN_DIR}\\\""; OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", "-fobjc-call-cxx-cdtors", diff --git a/Source/CDRSymbolicator.m b/Source/CDRSymbolicator.m index d9d78678..ffe1ebc9 100644 --- a/Source/CDRSymbolicator.m +++ b/Source/CDRSymbolicator.m @@ -209,7 +209,8 @@ - (void)launch { } // NB: this will almost always fail if the version of Xcode at this location differs from the version used to build the tests - NSString *output = [self.class shellOutWithCommand:@"/Applications/Xcode-beta.app/Contents/Developer/usr/bin/atos" arguments:arguments]; + NSString *command = [DEVELOPER_BIN_DIR stringByAppendingPathComponent:@"atos"]; + NSString *output = [self.class shellOutWithCommand:command arguments:arguments]; self.outputLines = [output componentsSeparatedByString:@"\n"]; } From b2774081646e9d969dc3ca88914e34f877b69793 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Sat, 12 Sep 2015 08:45:59 -0400 Subject: [PATCH 13/21] Fix broken header-copy item --- Cedar.xcodeproj/project.pbxproj | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index b7e6e384..c9a93d23 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -682,7 +682,6 @@ F7F4099B1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; F7F4099C1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; F7F4099D1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; - F7F4099F1B2E3E46001EFA14 /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F4099E1B2E3E26001EFA14 /* CDRPrivateFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1160,7 +1159,6 @@ E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectWithProperty.m; sourceTree = ""; }; F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestObserver.h; sourceTree = ""; }; F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestObserver.m; sourceTree = ""; }; - F7F4099E1B2E3E26001EFA14 /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2183,7 +2181,6 @@ AE4865D01B0690B0005DB302 /* ActualValue.h in Headers */, AE4865B41B0690AF005DB302 /* InvocationMatcher.h in Headers */, AE4865E31B0690B2005DB302 /* CDRBlockHelper.h in Headers */, - F7F4099F1B2E3E46001EFA14 /* CDRPrivateFunctions.h in Headers */, AE4865E51B0690B2005DB302 /* CDRNil.h in Headers */, AE48655D1B06769E005DB302 /* CDROTestRunner.h in Headers */, AE4865551B06769D005DB302 /* CDRBufferedDefaultReporter.h in Headers */, @@ -2335,7 +2332,7 @@ name = "Cedar iOS XCTest Tests"; productName = OCUnitAppTests; productReference = 1F45A3DD180E4796003C1E36 /* XCUnitAppTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; + productType = "com.apple.product-type.bundle"; }; 96A07EEE13F276640021974D /* Cedar OS X FocusedSpecs */ = { isa = PBXNativeTarget; @@ -2442,7 +2439,7 @@ name = "Cedar OS X Host AppTests"; productName = "OS X Host AppTests"; productReference = AE248FAA19DCD52500092C14 /* Cedar OS X Host AppTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; + productType = "com.apple.product-type.bundle"; }; AE4864F71B067620005DB302 /* Cedar-iOS-Framework */ = { isa = PBXNativeTarget; @@ -2478,7 +2475,7 @@ name = "Cedar OS X Failing Test Bundle"; productName = "OS X Failing Test Bundle"; productReference = AEB8818719DCD62D00F081BA /* Cedar OS X Failing Test Bundle.octest */; - productType = "com.apple.product-type.bundle.ocunit-test"; + productType = "com.apple.product-type.bundle"; }; AEEE1FB511DC271300029872 /* Cedar */ = { isa = PBXNativeTarget; From d945880b14fde0dbffb3228421069e1d70c6d145 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Sat, 12 Sep 2015 09:08:46 -0400 Subject: [PATCH 14/21] Make the OS X spec bundle pass under both Xcode 6 and 7 Also delete the OS X Failing Test Bundle because recent Xcode versions make it nearly impossible to link a test bundle without XCTest --- Cedar.xcodeproj/project.pbxproj | 190 +----------------- .../Cedar OS X Failing Test Bundle.xcscheme | 103 ---------- OS X Failing Test Bundle/ExampleSpec.mm | 38 ---- .../OS X Failing Test Bundle-Info.plist | 22 -- .../OS X Failing Test Bundle-Prefix.pch | 9 - .../en.lproj/InfoPlist.strings | 2 - OS X Host AppTests/OS_X_Host_AppTests.m | 7 +- OS X Host AppTests/TestObservationHelper.h | 5 + OS X Host AppTests/TestObservationHelper.m | 31 +++ Rakefile | 23 +-- .../Project/XCTest/CDRXCTestObserver.h | 8 +- Source/XCTest/CDRXCTestObserver.m | 20 +- 12 files changed, 57 insertions(+), 401 deletions(-) delete mode 100644 Cedar.xcodeproj/xcshareddata/xcschemes/Cedar OS X Failing Test Bundle.xcscheme delete mode 100644 OS X Failing Test Bundle/ExampleSpec.mm delete mode 100644 OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist delete mode 100644 OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch delete mode 100644 OS X Failing Test Bundle/en.lproj/InfoPlist.strings create mode 100644 OS X Host AppTests/TestObservationHelper.h create mode 100644 OS X Host AppTests/TestObservationHelper.m diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index c9a93d23..b4138292 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -81,6 +81,8 @@ 34681C2E18FE4884009D38AC /* CDRTypeUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2B18FE451E009D38AC /* CDRTypeUtilities.m */; }; 34681C3018FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */; }; 34681C3118FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */; }; + 34757E221BA466050047BC8D /* TestObservationHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 34757E201BA466050047BC8D /* TestObservationHelper.h */; settings = {ASSET_TAGS = (); }; }; + 34757E261BA4A48E0047BC8D /* TestObservationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34757E211BA466050047BC8D /* TestObservationHelper.m */; settings = {ASSET_TAGS = (); }; }; 34ADD2E01921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E11921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E71921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2E51921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm */; }; @@ -526,9 +528,6 @@ AEB1A74315F304A9002E4167 /* StubbedMethod.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEB1A74115F304A9002E4167 /* StubbedMethod.mm */; }; AEB45A911496C8D800845D09 /* RaiseException.h in Headers */ = {isa = PBXBuildFile; fileRef = AEB45A901496C8D800845D09 /* RaiseException.h */; settings = {ATTRIBUTES = (Public, ); }; }; AEB45A921496C8D800845D09 /* RaiseException.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = AEB45A901496C8D800845D09 /* RaiseException.h */; }; - AEB8818E19DCD62D00F081BA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AEB8818C19DCD62D00F081BA /* InfoPlist.strings */; }; - AEB8819019DCD62D00F081BA /* ExampleSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEB8818F19DCD62D00F081BA /* ExampleSpec.mm */; }; - AEB8819719DCD64100F081BA /* Cedar.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEEE1FB611DC271300029872 /* Cedar.framework */; }; AEB9B2CB1B23F5DF003E4728 /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = AEEF360D19DF24AB00794484 /* image.png */; }; AEB9B2CC1B23F5FB003E4728 /* edward.jpg in Resources */ = {isa = PBXBuildFile; fileRef = AEEF360F19DF27E400794484 /* edward.jpg */; }; AEBB92611496C1F000EEBD59 /* RaiseExceptionSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEBB92601496C1F000EEBD59 /* RaiseExceptionSpec.mm */; }; @@ -677,8 +676,6 @@ F78FDA1D1B43ABBC0054C768 /* ExpectFailureWithMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE8C87AB13624524006C9305 /* ExpectFailureWithMessage.mm */; }; F7A225DC1B43A8FB006231CC /* FooSuperclass.m in Sources */ = {isa = PBXBuildFile; fileRef = AED10EBB18F46C0E00950904 /* FooSuperclass.m */; }; F7BBE7D31B43A852009547F0 /* CedarDoubleSharedExamples.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE9AA69615ADB99800617E1A /* CedarDoubleSharedExamples.mm */; }; - F7F409981B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; - F7F4099A1B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */; }; F7F4099B1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; F7F4099C1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; F7F4099D1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */; }; @@ -741,13 +738,6 @@ remoteGlobalIDString = AEEE222811DC2B0600029872; remoteInfo = "Cedar-StaticLib"; }; - AEB8819219DCD62D00F081BA /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = AEEE1FA611DC26EA00029872 /* Project object */; - proxyType = 1; - remoteGlobalIDString = AEEE1FB511DC271300029872; - remoteInfo = Cedar; - }; AEEE218A11DC28E700029872 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = AEEE1FA611DC26EA00029872 /* Project object */; @@ -884,6 +874,8 @@ 34681C2B18FE451E009D38AC /* CDRTypeUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRTypeUtilities.m; sourceTree = ""; }; 34681C2D18FE4611009D38AC /* CDRTypeUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRTypeUtilities.h; sourceTree = ""; }; 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDRTypeUtilitiesSpec.mm; sourceTree = ""; }; + 34757E201BA466050047BC8D /* TestObservationHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObservationHelper.h; sourceTree = ""; }; + 34757E211BA466050047BC8D /* TestObservationHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObservationHelper.m; sourceTree = ""; }; 34ADD2DD1921F0B500B057AC /* AnyInstanceOfClassArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceOfClassArgument.h; sourceTree = ""; }; 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnyInstanceOfClassArgument.mm; sourceTree = ""; }; 34ADD2E41921F2F600B057AC /* AnyInstanceConformingToProtocolArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceConformingToProtocolArgument.h; sourceTree = ""; }; @@ -1048,11 +1040,6 @@ AEAA191119DCC5A900194E95 /* NSMethodSignature+Cedar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMethodSignature+Cedar.h"; sourceTree = ""; }; AEB1A74115F304A9002E4167 /* StubbedMethod.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StubbedMethod.mm; sourceTree = ""; }; AEB45A901496C8D800845D09 /* RaiseException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RaiseException.h; sourceTree = ""; }; - AEB8818719DCD62D00F081BA /* Cedar OS X Failing Test Bundle.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Cedar OS X Failing Test Bundle.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - AEB8818B19DCD62D00F081BA /* OS X Failing Test Bundle-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OS X Failing Test Bundle-Info.plist"; sourceTree = ""; }; - AEB8818D19DCD62D00F081BA /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - AEB8818F19DCD62D00F081BA /* ExampleSpec.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ExampleSpec.mm; sourceTree = ""; }; - AEB8819119DCD62D00F081BA /* OS X Failing Test Bundle-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OS X Failing Test Bundle-Prefix.pch"; sourceTree = ""; }; AEBB92601496C1F000EEBD59 /* RaiseExceptionSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RaiseExceptionSpec.mm; sourceTree = ""; }; AEBCDD7E173ACD6700B42B58 /* CDRDefaultReporterSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = CDRDefaultReporterSpec.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; AEC40C4E174AC4C000474D2D /* UIGeometryCompareEqual.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIGeometryCompareEqual.h; sourceTree = ""; }; @@ -1157,7 +1144,6 @@ E32861311604F287001FA77E /* FibonacciCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FibonacciCalculator.m; sourceTree = ""; }; E4BCFDD01817FA110083ED98 /* ObjectWithProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectWithProperty.h; sourceTree = ""; }; E4BCFDD11817FA110083ED98 /* ObjectWithProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectWithProperty.m; sourceTree = ""; }; - F7F409961B2E3C8B001EFA14 /* CDRXCTestObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestObserver.h; sourceTree = ""; }; F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestObserver.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1232,14 +1218,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - AEB8818419DCD62D00F081BA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - AEB8819719DCD64100F081BA /* Cedar.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AEEE1FB411DC271300029872 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1694,6 +1672,8 @@ isa = PBXGroup; children = ( AE248FB019DCD52500092C14 /* OS_X_Host_AppTests.m */, + 34757E201BA466050047BC8D /* TestObservationHelper.h */, + 34757E211BA466050047BC8D /* TestObservationHelper.m */, AE248FAE19DCD52500092C14 /* Supporting Files */, ); path = "OS X Host AppTests"; @@ -1765,25 +1745,6 @@ path = Arguments; sourceTree = ""; }; - AEB8818919DCD62D00F081BA /* OS X Failing Test Bundle */ = { - isa = PBXGroup; - children = ( - AEB8818F19DCD62D00F081BA /* ExampleSpec.mm */, - AEB8818A19DCD62D00F081BA /* Supporting Files */, - ); - path = "OS X Failing Test Bundle"; - sourceTree = ""; - }; - AEB8818A19DCD62D00F081BA /* Supporting Files */ = { - isa = PBXGroup; - children = ( - AEB8818B19DCD62D00F081BA /* OS X Failing Test Bundle-Info.plist */, - AEB8818C19DCD62D00F081BA /* InfoPlist.strings */, - AEB8819119DCD62D00F081BA /* OS X Failing Test Bundle-Prefix.pch */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; AEC40C4D174AC4C000474D2D /* UIKit */ = { isa = PBXGroup; children = ( @@ -1825,7 +1786,6 @@ 9668DCDE144A92BA007C7294 /* Test Bundle Support */, AE248F9919DCD52500092C14 /* OS X Host App */, AE248FAD19DCD52500092C14 /* OS X Host AppTests */, - AEB8818919DCD62D00F081BA /* OS X Failing Test Bundle */, AE4864F91B067621005DB302 /* Cedar-iOS-Framework */, AE03FBEA1B06C33B00013784 /* Cedar-iOS-Framework Spec */, AEEE202611DC286500029872 /* Frameworks */, @@ -1850,7 +1810,6 @@ AE02E7E4184EABCD00414F19 /* Cedar-iOS StaticFrameworkSpecs.app */, AE248F9819DCD52500092C14 /* Cedar OS X Host App.app */, AE248FAA19DCD52500092C14 /* Cedar OS X Host AppTests.xctest */, - AEB8818719DCD62D00F081BA /* Cedar OS X Failing Test Bundle.octest */, AE4864F81B067620005DB302 /* Cedar.framework */, AE03FBE91B06C33B00013784 /* Cedar-iOS-Framework Specs.app */, ); @@ -2120,7 +2079,6 @@ AE4865A71B0690AF005DB302 /* AnyInstanceArgument.h in Headers */, AE4865A81B0690AF005DB302 /* ReturnValue.h in Headers */, AE4865A91B0690AF005DB302 /* AnyArgument.h in Headers */, - F7F4099A1B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */, AE4865AA1B0690AF005DB302 /* AnyInstanceOfClassArgument.h in Headers */, AE4865AB1B0690AF005DB302 /* AnyInstanceConformingToProtocolArgument.h in Headers */, AE4865AC1B0690AF005DB302 /* CDRProtocolFake.h in Headers */, @@ -2242,7 +2200,6 @@ AEF8FB0719E6000E00DD4FE4 /* CDRVersion.h in Headers */, 34640DA81B6964FE0083EB01 /* CDRTypeUtilities.h in Headers */, B86B685F1A1326E200F283F7 /* OSXGeometryStringifiers.h in Headers */, - F7F409981B2E3C8B001EFA14 /* CDRXCTestObserver.h in Headers */, 2234907D18009DA6001C8E8D /* CDRHooks.h in Headers */, AE18A7CF13F453CC00C8872C /* BeTruthy.h in Headers */, AE18A7D013F453CC00C8872C /* Equal.h in Headers */, @@ -2279,6 +2236,7 @@ AE84F0DB145B70DD00769F85 /* ShouldSyntax.h in Headers */, 34147770191408C900CBA385 /* AnInstanceOf.h in Headers */, 34322B061BA7405800D0CFBD /* CDRPrivateFunctions.h in Headers */, + 34757E221BA466050047BC8D /* TestObservationHelper.h in Headers */, AE31A29F19C0F23F00C438C1 /* CDRXTestSuite.h in Headers */, AEB45A911496C8D800845D09 /* RaiseException.h in Headers */, AEC9DEED12C2CC7E0039512D /* CDRColorizedReporter.h in Headers */, @@ -2332,7 +2290,7 @@ name = "Cedar iOS XCTest Tests"; productName = OCUnitAppTests; productReference = 1F45A3DD180E4796003C1E36 /* XCUnitAppTests.xctest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.unit-test"; }; 96A07EEE13F276640021974D /* Cedar OS X FocusedSpecs */ = { isa = PBXNativeTarget; @@ -2439,7 +2397,7 @@ name = "Cedar OS X Host AppTests"; productName = "OS X Host AppTests"; productReference = AE248FAA19DCD52500092C14 /* Cedar OS X Host AppTests.xctest */; - productType = "com.apple.product-type.bundle"; + productType = "com.apple.product-type.bundle.unit-test"; }; AE4864F71B067620005DB302 /* Cedar-iOS-Framework */ = { isa = PBXNativeTarget; @@ -2459,24 +2417,6 @@ productReference = AE4864F81B067620005DB302 /* Cedar.framework */; productType = "com.apple.product-type.framework"; }; - AEB8818619DCD62D00F081BA /* Cedar OS X Failing Test Bundle */ = { - isa = PBXNativeTarget; - buildConfigurationList = AEB8819419DCD62E00F081BA /* Build configuration list for PBXNativeTarget "Cedar OS X Failing Test Bundle" */; - buildPhases = ( - AEB8818319DCD62D00F081BA /* Sources */, - AEB8818419DCD62D00F081BA /* Frameworks */, - AEB8818519DCD62D00F081BA /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - AEB8819319DCD62D00F081BA /* PBXTargetDependency */, - ); - name = "Cedar OS X Failing Test Bundle"; - productName = "OS X Failing Test Bundle"; - productReference = AEB8818719DCD62D00F081BA /* Cedar OS X Failing Test Bundle.octest */; - productType = "com.apple.product-type.bundle"; - }; AEEE1FB511DC271300029872 /* Cedar */ = { isa = PBXNativeTarget; buildConfigurationList = AEEE1FBC11DC271300029872 /* Build configuration list for PBXNativeTarget "Cedar" */; @@ -2571,9 +2511,6 @@ AE4864F71B067620005DB302 = { CreatedOnToolsVersion = 6.3.1; }; - AEB8818619DCD62D00F081BA = { - TestTargetID = AE248F9719DCD52500092C14; - }; }; }; buildConfigurationList = AEEE1FA911DC26EA00029872 /* Build configuration list for PBXProject "Cedar" */; @@ -2604,7 +2541,6 @@ 1F45A3C8180E4796003C1E36 /* Cedar iOS XCTest Tests */, AE248F9719DCD52500092C14 /* Cedar OS X Host App */, AE248FA919DCD52500092C14 /* Cedar OS X Host AppTests */, - AEB8818619DCD62D00F081BA /* Cedar OS X Failing Test Bundle */, AE4864F71B067620005DB302 /* Cedar-iOS-Framework */, AE03FBE81B06C33B00013784 /* Cedar-iOS-Framework Specs */, ); @@ -2668,14 +2604,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - AEB8818519DCD62D00F081BA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AEB8818E19DCD62D00F081BA /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AEEE1FB211DC271300029872 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -2912,6 +2840,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 34757E261BA4A48E0047BC8D /* TestObservationHelper.m in Sources */, AE248FB119DCD52500092C14 /* OS_X_Host_AppTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2973,14 +2902,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - AEB8818319DCD62D00F081BA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AEB8819019DCD62D00F081BA /* ExampleSpec.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; AEEE1FB311DC271300029872 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3273,11 +3194,6 @@ target = AEEE222811DC2B0600029872 /* Cedar-StaticLib */; targetProxy = AE4865A21B067F53005DB302 /* PBXContainerItemProxy */; }; - AEB8819319DCD62D00F081BA /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = AEEE1FB511DC271300029872 /* Cedar */; - targetProxy = AEB8819219DCD62D00F081BA /* PBXContainerItemProxy */; - }; AEEE218B11DC28E700029872 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = AEEE1FB511DC271300029872 /* Cedar */; @@ -3326,14 +3242,6 @@ name = InfoPlist.strings; sourceTree = ""; }; - AEB8818C19DCD62D00F081BA /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - AEB8818D19DCD62D00F081BA /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -3898,75 +3806,6 @@ }; name = Release; }; - AEB8819519DCD62E00F081BA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Cedar OS X Host App.app/Contents/MacOS/Cedar OS X Host App"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - COMBINE_HIDPI_IMAGES = YES; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - INFOPLIST_FILE = "OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - AEB8819619DCD62E00F081BA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Cedar OS X Host App.app/Contents/MacOS/Cedar OS X Host App"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - COMBINE_HIDPI_IMAGES = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(DEVELOPER_FRAMEWORKS_DIR)", - "$(inherited)", - ); - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch"; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - INFOPLIST_FILE = "OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Release; - }; AEEE1FA711DC26EA00029872 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4376,15 +4215,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - AEB8819419DCD62E00F081BA /* Build configuration list for PBXNativeTarget "Cedar OS X Failing Test Bundle" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AEB8819519DCD62E00F081BA /* Debug */, - AEB8819619DCD62E00F081BA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; AEEE1FA911DC26EA00029872 /* Build configuration list for PBXProject "Cedar" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar OS X Failing Test Bundle.xcscheme b/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar OS X Failing Test Bundle.xcscheme deleted file mode 100644 index 02b9e011..00000000 --- a/Cedar.xcodeproj/xcshareddata/xcschemes/Cedar OS X Failing Test Bundle.xcscheme +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OS X Failing Test Bundle/ExampleSpec.mm b/OS X Failing Test Bundle/ExampleSpec.mm deleted file mode 100644 index 4c49a60b..00000000 --- a/OS X Failing Test Bundle/ExampleSpec.mm +++ /dev/null @@ -1,38 +0,0 @@ -#import - -using namespace Cedar::Matchers; -using namespace Cedar::Doubles; - -SPEC_BEGIN(ExampleSpec) - -/* This is not an exhaustive list of usages. - For more information, please visit https://github.com/pivotal/cedar */ - -describe(@"Example specs on NSString", ^{ - - it(@"lowercaseString returns a new string with everything in lower case", ^{ - [@"FOOBar" lowercaseString] should equal(@"foobar"); - }); - - it(@"length returns the number of characters in the string", ^{ - [@"internationalization" length] should equal(20); - }); - - describe(@"isEqualToString:", ^{ - it(@"should return true if the strings are the same", ^{ - [@"someString" isEqualToString:@"someString"] should be_truthy; - }); - - it(@"should return false if the strings are not the same", ^{ - [@"someString" isEqualToString:@"anotherString"] should_not be_truthy; - }); - }); - - describe(@"NSMutableString", ^{ - it(@"should be a kind of NSString", ^{ - [NSMutableString string] should be_instance_of([NSString class]).or_any_subclass(); - }); - }); -}); - -SPEC_END diff --git a/OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist b/OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist deleted file mode 100644 index 0f88d375..00000000 --- a/OS X Failing Test Bundle/OS X Failing Test Bundle-Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.pivotallabs.cedar.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch b/OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch deleted file mode 100644 index 35d76409..00000000 --- a/OS X Failing Test Bundle/OS X Failing Test Bundle-Prefix.pch +++ /dev/null @@ -1,9 +0,0 @@ -// -// Prefix header -// -// The contents of this file are implicitly included at the beginning of every source file. -// - -#ifdef __OBJC__ - #import -#endif diff --git a/OS X Failing Test Bundle/en.lproj/InfoPlist.strings b/OS X Failing Test Bundle/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28ff..00000000 --- a/OS X Failing Test Bundle/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/OS X Host AppTests/OS_X_Host_AppTests.m b/OS X Host AppTests/OS_X_Host_AppTests.m index e7ed70d4..d59c2cd6 100644 --- a/OS X Host AppTests/OS_X_Host_AppTests.m +++ b/OS X Host AppTests/OS_X_Host_AppTests.m @@ -1,8 +1,8 @@ #import #import +#import "TestObservationHelper.h" @interface OS_X_Host_AppTests : XCTestCase - @end @implementation OS_X_Host_AppTests @@ -12,7 +12,8 @@ - (void)testMainBundleIsTheAppBundle { } - (void)testRunningCedarExamples { - XCTestSuite *defaultSuite = [XCTestSuite defaultTestSuite]; - XCTAssert([[defaultSuite valueForKeyPath:@"tests.name"] containsObject:@"Cedar"]); + NSArray *knownTestSuites = [TestObservationHelper knownTestSuites]; + XCTAssert([[knownTestSuites valueForKeyPath:@"@unionOfArrays.tests.name"] containsObject:@"Cedar"]); } + @end diff --git a/OS X Host AppTests/TestObservationHelper.h b/OS X Host AppTests/TestObservationHelper.h new file mode 100644 index 00000000..146436cf --- /dev/null +++ b/OS X Host AppTests/TestObservationHelper.h @@ -0,0 +1,5 @@ +#import + +@interface TestObservationHelper : NSObject ++ (NSArray *)knownTestSuites; +@end diff --git a/OS X Host AppTests/TestObservationHelper.m b/OS X Host AppTests/TestObservationHelper.m new file mode 100644 index 00000000..7a65e701 --- /dev/null +++ b/OS X Host AppTests/TestObservationHelper.m @@ -0,0 +1,31 @@ +#import "TestObservationHelper.h" +#import "CDRXCTestObserver.h" + +@interface XCTestSuite ++ (instancetype)defaultTestSuite; +@end + +@interface TestObservationHelper () @end + +@implementation TestObservationHelper + +static NSMutableArray *_knownTestSuites; + ++ (void)load { + Class observationCenterClass = NSClassFromString(@"XCTestObservationCenter"); + if (observationCenterClass && [observationCenterClass respondsToSelector:@selector(sharedTestObservationCenter)]) { + _knownTestSuites = [NSMutableArray array]; + + [[observationCenterClass sharedTestObservationCenter] addTestObserver:(id)[TestObservationHelper new]]; + } +} + ++ (NSArray *)knownTestSuites { + return [_knownTestSuites copy] ?: @[[XCTestSuite defaultTestSuite]]; +} + +- (void)testSuiteWillStart:(XCTestSuite *)suite { + [_knownTestSuites addObject:suite]; +} + +@end diff --git a/Rakefile b/Rakefile index 9aa76129..11baccfe 100644 --- a/Rakefile +++ b/Rakefile @@ -11,8 +11,6 @@ IOS_DYNAMIC_FRAMEWORK_SPECS_TARGET_NAME = "Cedar-iOS-Framework Specs" XCUNIT_APPLICATION_SPECS_SCHEME_NAME = "Cedar iOS XCTest Tests" -OSX_FAILING_SPEC_SCHEME_NAME = "Cedar OS X Failing Test Bundle" - CEDAR_FRAMEWORK_TARGET_NAME = "Cedar" CEDAR_IOS_STATIC_FRAMEWORK_TARGET_NAME = "Cedar-iOS" CEDAR_IOS_DYNAMIC_FRAMEWORK_TARGET_NAME = "Cedar-iOS-Framework" @@ -461,7 +459,7 @@ end namespace :testbundles do desc "Runs all test bundle test suites (xcunit)" - task run: ['testbundles:xcunit', 'testbundles:failing_test_bundle'] + task run: ['testbundles:xcunit'] desc "Converts the test bundle identifier to ones Xcode 5- recognizes (Xcode 6 postfixes the original bundler identifier)" task :convert_to_xcode5 do @@ -479,25 +477,6 @@ namespace :testbundles do logfile: "xcunit.run.log", ) end - - desc 'A target that does not have XCTest or SenTestingKit linked should alert the user' - task :failing_test_bundle do - the_exception = nil - - begin - Xcode.test( - scheme: OSX_FAILING_SPEC_SCHEME_NAME, - logfile: "failing.osx.specs.log", - args: "2>&1", - ) - rescue Exception => e - the_exception = e - end - - unless the_exception && the_exception.to_s =~ /CedarNoTestFrameworkAvailable/ - raise the_exception - end - end end desc "Remove code snippets and templates" diff --git a/Source/Headers/Project/XCTest/CDRXCTestObserver.h b/Source/Headers/Project/XCTest/CDRXCTestObserver.h index 2c210438..ccdd3a1b 100644 --- a/Source/Headers/Project/XCTest/CDRXCTestObserver.h +++ b/Source/Headers/Project/XCTest/CDRXCTestObserver.h @@ -2,20 +2,14 @@ @class XCTestSuite; @protocol XCTestObservation +@optional - (void)testBundleDidFinish:(NSBundle *)testBundle; -- (void)testSuiteWillStart:(XCTestSuite *)testSuite; @end -@class XCTestObservationCenter; @interface XCTestObservationCenter -@end - -@interface XCTestObservationCenter (CDRVisibility) + (instancetype)sharedTestObservationCenter; - (void)addTestObserver:(id)observer; -- (void)removeTestObserver:(id)observer; @end @interface CDRXCTestObserver : NSObject - @end diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index 02219247..1cc81631 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -9,19 +9,17 @@ #import "CDRXTestSuite.h" #import "CDRRuntimeUtilities.h" -CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); +static id CDRCreateXCTestSuite(); +static CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); @interface CDRXCTestObserver () -@property (retain) CDRReportDispatcher *dispatcher; @property (assign) BOOL observedTestSuiteStart; @end @interface CDRXCTestSupport : NSObject -- (id)testSuiteWithName:(NSString *)name; - (id)defaultTestSuite; -- (id)testSuiteForBundlePath:(NSString *)bundlePath; - (id)initWithName:(NSString *)aName; - (id)CDR_original_defaultTestSuite; @@ -37,16 +35,8 @@ - (void)testSuiteWillStart:(XCTestSuite *)testSuite { } self.observedTestSuiteStart = YES; - self.dispatcher = CDRAddCedarSpecsToXCTestSuite(testSuite); -} - -- (void)testBundleDidFinish:(NSBundle *)testBundle { - [self.dispatcher runDidComplete]; -} - -- (void)dealloc { - self.dispatcher = nil; - [super dealloc]; + id cedarTestSuite = CDRCreateXCTestSuite(); + [testSuite addTest:cedarTestSuite]; } @end @@ -98,7 +88,7 @@ void CDRInjectIntoXCTestRunner() { class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); } -CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { +static CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { unsigned int seed = CDRGetRandomSeed(); CDRDefineSharedExampleGroups(); From cb93da0084e0a2f885eab271d3122fe9947bc2fa Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Sun, 13 Sep 2015 23:28:32 -0400 Subject: [PATCH 15/21] Miscellaneous cleanups to the test bundle bootstrap code --- Cedar.xcodeproj/project.pbxproj | 80 ++++++++------- OS X Host AppTests/TestObservationHelper.m | 2 +- ...CDROTestRunner.m => CDRTestBundleRunner.m} | 8 +- Source/Headers/Project/CDROTestRunner.h | 5 - Source/Headers/Project/CDRPrivateFunctions.h | 1 + Source/Headers/Project/XCTest/CDRXCTestCase.h | 2 + .../Project/XCTest/CDRXCTestObserver.h | 12 +-- .../Headers/Project/XCTest/CDRXCTestSuite.h | 13 +++ .../Headers/Project/XCTest/CDRXCTestSupport.h | 29 ++++++ Source/Headers/Project/XCTest/CDRXTestSuite.h | 10 -- Source/XCTest/CDRXCTestFunctions.m | 83 ++++++++++++++++ Source/XCTest/CDRXCTestObserver.m | 97 ------------------- .../{CDRXTestSuite.m => CDRXCTestSuite.m} | 5 +- Spec/iPhone/XCTest/CDRXTestSuiteSpec.mm | 11 +-- 14 files changed, 184 insertions(+), 174 deletions(-) rename Source/{CDROTestRunner.m => CDRTestBundleRunner.m} (50%) delete mode 100644 Source/Headers/Project/CDROTestRunner.h create mode 100644 Source/Headers/Project/XCTest/CDRXCTestSuite.h create mode 100644 Source/Headers/Project/XCTest/CDRXCTestSupport.h delete mode 100644 Source/Headers/Project/XCTest/CDRXTestSuite.h create mode 100644 Source/XCTest/CDRXCTestFunctions.m rename Source/XCTest/{CDRXTestSuite.m => CDRXCTestSuite.m} (88%) diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index b4138292..977b8a1d 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -68,10 +68,9 @@ 34157D101B755E21007AD1BA /* CDRTeamCityReporter.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 42064465139B44EC00C85605 /* CDRTeamCityReporter.h */; }; 34157D111B755E40007AD1BA /* CDRBufferedDefaultReporter.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */; }; 342F5D0B18F430DB00F38E35 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 342F5D0A18F430DB00F38E35 /* QuartzCore.framework */; }; - 34322B061BA7405800D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; - 34322B071BA7406100D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; 34322B091BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; 34322B0A1BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; + 34322B0B1BA742B400D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; 343FAFEA190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 343FAFEB190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 34640DA71B6964F90083EB01 /* CDRBlockHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */; }; @@ -81,8 +80,13 @@ 34681C2E18FE4884009D38AC /* CDRTypeUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2B18FE451E009D38AC /* CDRTypeUtilities.m */; }; 34681C3018FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */; }; 34681C3118FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */; }; - 34757E221BA466050047BC8D /* TestObservationHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 34757E201BA466050047BC8D /* TestObservationHelper.h */; settings = {ASSET_TAGS = (); }; }; - 34757E261BA4A48E0047BC8D /* TestObservationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34757E211BA466050047BC8D /* TestObservationHelper.m */; settings = {ASSET_TAGS = (); }; }; + 34757E261BA4A48E0047BC8D /* TestObservationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34757E211BA466050047BC8D /* TestObservationHelper.m */; }; + 34777EB71B99451200A69FCF /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */; }; + 3492DA971BA670C10032B35A /* CDRXCTestFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */; }; + 3492DA981BA670C10032B35A /* CDRXCTestFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */; }; + 3492DA991BA670C10032B35A /* CDRXCTestFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */; }; + 3492DA9B1BA672AB0032B35A /* CDRXCTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */; }; + 3492DA9C1BA672AD0032B35A /* CDRXCTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */; }; 34ADD2E01921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E11921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E71921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2E51921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm */; }; @@ -152,9 +156,8 @@ 96D34482144A82DB00352C4A /* DummyView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96D3447F144A82D100352C4A /* DummyView.xib */; }; 96EA1CA8142C6425001A78E0 /* CDROTestReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */; }; 96EA1CA9142C6425001A78E0 /* CDROTestReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */; }; - 96EA1CAA142C6425001A78E0 /* CDROTestRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */; }; + 96EA1CAA142C6425001A78E0 /* CDRTestBundleRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDRTestBundleRunner.m */; }; 96EA1CAE142C6449001A78E0 /* CDROTestReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 96EA1CAC142C6449001A78E0 /* CDROTestReporter.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 96EA1CB0142C6449001A78E0 /* CDROTestRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 96EA1CAD142C6449001A78E0 /* CDROTestRunner.h */; }; 96EA1CBA142C6560001A78E0 /* CDRSpecFailureSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */; }; 96EA1CBB142C6560001A78E0 /* CDRSpecFailureSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */; }; 9D28051918E2321D00887CC4 /* ObjectWithValueEquality.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D28051818E2321D00887CC4 /* ObjectWithValueEquality.m */; }; @@ -288,9 +291,9 @@ AE248FA019DCD52500092C14 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AE248F9F19DCD52500092C14 /* AppDelegate.m */; }; AE248FB119DCD52500092C14 /* OS_X_Host_AppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AE248FB019DCD52500092C14 /* OS_X_Host_AppTests.m */; }; AE248FB819DCD54600092C14 /* Cedar.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AEEE1FB611DC271300029872 /* Cedar.framework */; }; - AE31A29F19C0F23F00C438C1 /* CDRXTestSuite.h in Headers */ = {isa = PBXBuildFile; fileRef = AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */; }; - AE31A2A119C0F23F00C438C1 /* CDRXTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */; }; - AE31A2A219C0F23F00C438C1 /* CDRXTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */; }; + AE31A29F19C0F23F00C438C1 /* CDRXCTestSuite.h in Headers */ = {isa = PBXBuildFile; fileRef = AE31A29D19C0F23F00C438C1 /* CDRXCTestSuite.h */; }; + AE31A2A119C0F23F00C438C1 /* CDRXCTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXCTestSuite.m */; }; + AE31A2A219C0F23F00C438C1 /* CDRXCTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXCTestSuite.m */; }; AE34722819C11872005CA6F1 /* GlobalBeforeEachSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF011DC27B800029872 /* GlobalBeforeEachSpec.mm */; }; AE34722A19C118C9005CA6F1 /* SpecSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FF111DC27B800029872 /* SpecSpec.mm */; }; AE34722F19C124CE005CA6F1 /* CDRExampleSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FE911DC27B800029872 /* CDRExampleSpec.mm */; }; @@ -312,9 +315,8 @@ AE4865231B06769B005DB302 /* CedarDoubleImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = AE9AA6DA15AE0B0300617E1A /* CedarDoubleImpl.h */; }; AE4865531B06769D005DB302 /* CDRReportDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FE15C191869091900207F0C /* CDRReportDispatcher.h */; }; AE4865551B06769D005DB302 /* CDRBufferedDefaultReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FF449B318A0C04D00AF94B0 /* CDRBufferedDefaultReporter.h */; settings = {ATTRIBUTES = (Public, ); }; }; - AE48655D1B06769E005DB302 /* CDROTestRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 96EA1CAD142C6449001A78E0 /* CDROTestRunner.h */; }; AE4865661B06769F005DB302 /* CDRRuntimeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = AE55BF1D19A7CF83005948E6 /* CDRRuntimeUtilities.h */; }; - AE4865681B06769F005DB302 /* CDRXTestSuite.h in Headers */ = {isa = PBXBuildFile; fileRef = AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */; }; + AE4865681B06769F005DB302 /* CDRXCTestSuite.h in Headers */ = {isa = PBXBuildFile; fileRef = AE31A29D19C0F23F00C438C1 /* CDRXCTestSuite.h */; }; AE4865691B06769F005DB302 /* CDRXCTestCase.h in Headers */ = {isa = PBXBuildFile; fileRef = AE34724919C37ECF005CA6F1 /* CDRXCTestCase.h */; }; AE48656A1B06769F005DB302 /* NSInvocation+CDRXExample.h in Headers */ = {isa = PBXBuildFile; fileRef = AE4E9B9019C8B44700D794CE /* NSInvocation+CDRXExample.h */; }; AE48656B1B06769F005DB302 /* CDROTestNamer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F483E30187D39D000521F81 /* CDROTestNamer.h */; }; @@ -336,7 +338,7 @@ AE48657E1B067953005DB302 /* NSInvocation+Cedar.m in Sources */ = {isa = PBXBuildFile; fileRef = AE7F1705172730B000E1146D /* NSInvocation+Cedar.m */; }; AE48657F1B067953005DB302 /* NSMethodSignature+Cedar.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ADE41618F23C8E00BD1E99 /* NSMethodSignature+Cedar.m */; }; AE4865801B067953005DB302 /* CDRSpec+XCTestSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = AE0C9D8B19C0C64200B4DD2B /* CDRSpec+XCTestSupport.m */; }; - AE4865811B067953005DB302 /* CDRXTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */; }; + AE4865811B067953005DB302 /* CDRXCTestSuite.m in Sources */ = {isa = PBXBuildFile; fileRef = AE31A29E19C0F23F00C438C1 /* CDRXCTestSuite.m */; }; AE4865821B067953005DB302 /* CDRXCTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = AE34724A19C37ECF005CA6F1 /* CDRXCTestCase.m */; }; AE4865831B067953005DB302 /* NSInvocation+CDRXExample.m in Sources */ = {isa = PBXBuildFile; fileRef = AE4E9B9119C8B44700D794CE /* NSInvocation+CDRXExample.m */; }; AE4865841B067953005DB302 /* NSBundle+MainBundleHijack.m in Sources */ = {isa = PBXBuildFile; fileRef = 960118BB1434867E00825FFF /* NSBundle+MainBundleHijack.m */; }; @@ -358,7 +360,7 @@ AE4865941B067954005DB302 /* CDRExampleBase.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FC611DC27B800029872 /* CDRExampleBase.m */; }; AE4865951B067954005DB302 /* CDRExampleGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FC711DC27B800029872 /* CDRExampleGroup.m */; }; AE4865961B067954005DB302 /* CDRFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FC811DC27B800029872 /* CDRFunctions.m */; }; - AE4865971B067954005DB302 /* CDROTestRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */; }; + AE4865971B067954005DB302 /* CDRTestBundleRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDRTestBundleRunner.m */; }; AE4865981B067954005DB302 /* CDRRuntimeUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = AE55BF1A19A7CF58005948E6 /* CDRRuntimeUtilities.m */; }; AE4865991B067954005DB302 /* CDRSharedExampleGroupPool.m in Sources */ = {isa = PBXBuildFile; fileRef = AEFD17B111DD1E7200F4448A /* CDRSharedExampleGroupPool.m */; }; AE48659A1B067954005DB302 /* CDRSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEE1FC911DC27B800029872 /* CDRSpec.m */; }; @@ -521,7 +523,7 @@ AE9BA627184D203000079A97 /* ConformTo.h in Copy headers to framework */ = {isa = PBXBuildFile; fileRef = 5898AEAF3FE8C683E6F23C1D /* ConformTo.h */; }; AE9EAAD9178C789800CCF7DA /* CDRDefaultReporterSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEBCDD7E173ACD6700B42B58 /* CDRDefaultReporterSpec.mm */; }; AE9EAADA178C789900CCF7DA /* CDRDefaultReporterSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEBCDD7E173ACD6700B42B58 /* CDRDefaultReporterSpec.mm */; }; - AEA8962C19D0C242007D5C08 /* CDROTestRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */; }; + AEA8962C19D0C242007D5C08 /* CDRTestBundleRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 96EA1CA7142C6425001A78E0 /* CDRTestBundleRunner.m */; }; AEAA191219DCC5A900194E95 /* NSInvocation+Cedar.h in Headers */ = {isa = PBXBuildFile; fileRef = AEAA191019DCC5A900194E95 /* NSInvocation+Cedar.h */; }; AEAA191419DCC5A900194E95 /* NSMethodSignature+Cedar.h in Headers */ = {isa = PBXBuildFile; fileRef = AEAA191119DCC5A900194E95 /* NSMethodSignature+Cedar.h */; }; AEB1A74215F304A9002E4167 /* StubbedMethod.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEB1A74115F304A9002E4167 /* StubbedMethod.mm */; }; @@ -866,7 +868,6 @@ 2234907C18009DA6001C8E8D /* CDRHooks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRHooks.h; sourceTree = ""; }; 228F3FA617E3ECD10000C8AF /* CDRSpyiOSSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = CDRSpyiOSSpec.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 342F5D0A18F430DB00F38E35 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; }; - 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestObserver.h; sourceTree = ""; }; 343FAFE8190FDAEC0085AFEC /* DeallocNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeallocNotifier.h; sourceTree = ""; }; 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeallocNotifier.m; sourceTree = ""; }; @@ -876,6 +877,9 @@ 34681C2F18FE4B68009D38AC /* CDRTypeUtilitiesSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDRTypeUtilitiesSpec.mm; sourceTree = ""; }; 34757E201BA466050047BC8D /* TestObservationHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObservationHelper.h; sourceTree = ""; }; 34757E211BA466050047BC8D /* TestObservationHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObservationHelper.m; sourceTree = ""; }; + 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; + 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestFunctions.m; sourceTree = ""; }; + 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRXCTestSupport.h; sourceTree = ""; }; 34ADD2DD1921F0B500B057AC /* AnyInstanceOfClassArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceOfClassArgument.h; sourceTree = ""; }; 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnyInstanceOfClassArgument.mm; sourceTree = ""; }; 34ADD2E41921F2F600B057AC /* AnyInstanceConformingToProtocolArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceConformingToProtocolArgument.h; sourceTree = ""; }; @@ -939,9 +943,8 @@ 96D34480144A82D100352C4A /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DummyView.xib; sourceTree = ""; }; 96D34483144A845100352C4A /* OCUnitApplicationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCUnitApplicationTests.mm; sourceTree = ""; }; 96EA1CA6142C6425001A78E0 /* CDROTestReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CDROTestReporter.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDROTestRunner.m; sourceTree = ""; }; + 96EA1CA7142C6425001A78E0 /* CDRTestBundleRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRTestBundleRunner.m; sourceTree = ""; }; 96EA1CAC142C6449001A78E0 /* CDROTestReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDROTestReporter.h; sourceTree = ""; }; - 96EA1CAD142C6449001A78E0 /* CDROTestRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDROTestRunner.h; sourceTree = ""; }; 96EA1CB9142C6560001A78E0 /* CDRSpecFailureSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = CDRSpecFailureSpec.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 9D28051718E2321D00887CC4 /* ObjectWithValueEquality.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectWithValueEquality.h; sourceTree = ""; }; 9D28051818E2321D00887CC4 /* ObjectWithValueEquality.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectWithValueEquality.m; sourceTree = ""; }; @@ -983,8 +986,8 @@ AE248FAA19DCD52500092C14 /* Cedar OS X Host AppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Cedar OS X Host AppTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; AE248FAF19DCD52500092C14 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AE248FB019DCD52500092C14 /* OS_X_Host_AppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OS_X_Host_AppTests.m; sourceTree = ""; }; - AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXTestSuite.h; sourceTree = ""; }; - AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXTestSuite.m; sourceTree = ""; }; + AE31A29D19C0F23F00C438C1 /* CDRXCTestSuite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestSuite.h; sourceTree = ""; }; + AE31A29E19C0F23F00C438C1 /* CDRXCTestSuite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestSuite.m; sourceTree = ""; }; AE34724019C2259B005CA6F1 /* CDRXTestSuiteSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CDRXTestSuiteSpec.mm; sourceTree = ""; }; AE34724919C37ECF005CA6F1 /* CDRXCTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRXCTestCase.h; sourceTree = ""; }; AE34724A19C37ECF005CA6F1 /* CDRXCTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestCase.m; sourceTree = ""; }; @@ -1345,8 +1348,7 @@ 34157D181B75A212007AD1BA /* XCTest */, 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */, 34F3DF7B1A6ABA2E003041DA /* CDRNil.h */, - 96EA1CAD142C6449001A78E0 /* CDROTestRunner.h */, - 34322B051BA7405800D0CFBD /* CDRPrivateFunctions.h */, + 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */, AE55BF1D19A7CF83005948E6 /* CDRRuntimeUtilities.h */, 969B6F95160F1FEC00C7C792 /* CDRSymbolicator.h */, 34681C2D18FE4611009D38AC /* CDRTypeUtilities.h */, @@ -1394,7 +1396,8 @@ children = ( AE34724919C37ECF005CA6F1 /* CDRXCTestCase.h */, 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */, - AE31A29D19C0F23F00C438C1 /* CDRXTestSuite.h */, + AE31A29D19C0F23F00C438C1 /* CDRXCTestSuite.h */, + 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */, AE4E9B9019C8B44700D794CE /* NSInvocation+CDRXExample.h */, ); path = XCTest; @@ -1592,10 +1595,11 @@ isa = PBXGroup; children = ( AE0C9D8B19C0C64200B4DD2B /* CDRSpec+XCTestSupport.m */, - AE31A29E19C0F23F00C438C1 /* CDRXTestSuite.m */, AE34724A19C37ECF005CA6F1 /* CDRXCTestCase.m */, + AE31A29E19C0F23F00C438C1 /* CDRXCTestSuite.m */, F7F409971B2E3C8B001EFA14 /* CDRXCTestObserver.m */, AE4E9B9119C8B44700D794CE /* NSInvocation+CDRXExample.m */, + 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */, ); path = XCTest; sourceTree = ""; @@ -1831,7 +1835,7 @@ AEEE1FC611DC27B800029872 /* CDRExampleBase.m */, AEEE1FC711DC27B800029872 /* CDRExampleGroup.m */, AEEE1FC811DC27B800029872 /* CDRFunctions.m */, - 96EA1CA7142C6425001A78E0 /* CDROTestRunner.m */, + 96EA1CA7142C6425001A78E0 /* CDRTestBundleRunner.m */, AE55BF1A19A7CF58005948E6 /* CDRRuntimeUtilities.m */, AEFD17B111DD1E7200F4448A /* CDRSharedExampleGroupPool.m */, AEEE1FC911DC27B800029872 /* CDRSpec.m */, @@ -2140,19 +2144,19 @@ AE4865B41B0690AF005DB302 /* InvocationMatcher.h in Headers */, AE4865E31B0690B2005DB302 /* CDRBlockHelper.h in Headers */, AE4865E51B0690B2005DB302 /* CDRNil.h in Headers */, - AE48655D1B06769E005DB302 /* CDROTestRunner.h in Headers */, AE4865551B06769D005DB302 /* CDRBufferedDefaultReporter.h in Headers */, - AE4865681B06769F005DB302 /* CDRXTestSuite.h in Headers */, + AE4865681B06769F005DB302 /* CDRXCTestSuite.h in Headers */, AE4865E41B0690B2005DB302 /* CDRTypeUtilities.h in Headers */, AE4865A41B0690AF005DB302 /* NSInvocation+Cedar.h in Headers */, AE4865121B06769B005DB302 /* NSMethodSignature+Cedar.h in Headers */, + 3492DA9C1BA672AD0032B35A /* CDRXCTestSupport.h in Headers */, AE4865E71B0691C9005DB302 /* CDRColorizedReporter.h in Headers */, AE48656A1B06769F005DB302 /* NSInvocation+CDRXExample.h in Headers */, AE4865231B06769B005DB302 /* CedarDoubleImpl.h in Headers */, AE48651D1B06769B005DB302 /* CDRSpyInfo.h in Headers */, AE4865E81B0691EA005DB302 /* CDRTeamCityReporter.h in Headers */, AE4865691B06769F005DB302 /* CDRXCTestCase.h in Headers */, - 34322B071BA7406100D0CFBD /* CDRPrivateFunctions.h in Headers */, + 34322B0B1BA742B400D0CFBD /* CDRPrivateFunctions.h in Headers */, AE4865EC1B069253005DB302 /* CDROTestReporter.h in Headers */, AE4865EA1B069253005DB302 /* CDRExampleReporter.h in Headers */, AE4865531B06769D005DB302 /* CDRReportDispatcher.h in Headers */, @@ -2180,12 +2184,12 @@ AEEE200811DC27B800029872 /* CDRSpecHelper.h in Headers */, AE91CA6C11DE64A3002BA6B9 /* CDRSharedExampleGroupPool.h in Headers */, 1FE15C1B1869091900207F0C /* CDRReportDispatcher.h in Headers */, + 3492DA9B1BA672AB0032B35A /* CDRXCTestSupport.h in Headers */, AE8C880F13626FA5006C9305 /* CDRSpecFailure.h in Headers */, AE0AF56513E9C0E300029396 /* CedarMatchers.h in Headers */, AE0AF58513E9E87E00029396 /* ActualValue.h in Headers */, AEF72F7813EC730700786282 /* CedarComparators.h in Headers */, AEF72F7B13EC734000786282 /* CedarStringifiers.h in Headers */, - 96EA1CB0142C6449001A78E0 /* CDROTestRunner.h in Headers */, AE4E9B9219C8B44700D794CE /* NSInvocation+CDRXExample.h in Headers */, 34640DA91B6965060083EB01 /* CDRNil.h in Headers */, AEF7301113ECC25000786282 /* BeEmpty.h in Headers */, @@ -2235,9 +2239,8 @@ 969B6F96160F1FEC00C7C792 /* CDRSymbolicator.h in Headers */, AE84F0DB145B70DD00769F85 /* ShouldSyntax.h in Headers */, 34147770191408C900CBA385 /* AnInstanceOf.h in Headers */, - 34322B061BA7405800D0CFBD /* CDRPrivateFunctions.h in Headers */, - 34757E221BA466050047BC8D /* TestObservationHelper.h in Headers */, - AE31A29F19C0F23F00C438C1 /* CDRXTestSuite.h in Headers */, + AE31A29F19C0F23F00C438C1 /* CDRXCTestSuite.h in Headers */, + 34777EB71B99451200A69FCF /* CDRPrivateFunctions.h in Headers */, AEB45A911496C8D800845D09 /* RaiseException.h in Headers */, AEC9DEED12C2CC7E0039512D /* CDRColorizedReporter.h in Headers */, 96EA1CAE142C6449001A78E0 /* CDROTestReporter.h in Headers */, @@ -2868,8 +2871,9 @@ F7F4099D1B2E3C8B001EFA14 /* CDRXCTestObserver.m in Sources */, AE48657F1B067953005DB302 /* NSMethodSignature+Cedar.m in Sources */, AE4865801B067953005DB302 /* CDRSpec+XCTestSupport.m in Sources */, - AE4865811B067953005DB302 /* CDRXTestSuite.m in Sources */, + AE4865811B067953005DB302 /* CDRXCTestSuite.m in Sources */, AE4865821B067953005DB302 /* CDRXCTestCase.m in Sources */, + 3492DA991BA670C10032B35A /* CDRXCTestFunctions.m in Sources */, AE4865831B067953005DB302 /* NSInvocation+CDRXExample.m in Sources */, AE4865841B067953005DB302 /* NSBundle+MainBundleHijack.m in Sources */, AE4865851B067953005DB302 /* CedarApplicationDelegate.m in Sources */, @@ -2890,7 +2894,7 @@ AE4865941B067954005DB302 /* CDRExampleBase.m in Sources */, AE4865951B067954005DB302 /* CDRExampleGroup.m in Sources */, AE4865961B067954005DB302 /* CDRFunctions.m in Sources */, - AE4865971B067954005DB302 /* CDROTestRunner.m in Sources */, + AE4865971B067954005DB302 /* CDRTestBundleRunner.m in Sources */, AE4865981B067954005DB302 /* CDRRuntimeUtilities.m in Sources */, AE4865991B067954005DB302 /* CDRSharedExampleGroupPool.m in Sources */, AE48659A1B067954005DB302 /* CDRSpec.m in Sources */, @@ -2909,10 +2913,11 @@ AE4A946118807DA6008566F5 /* RejectedMethod.mm in Sources */, AEEE1FF311DC27B800029872 /* CDRDefaultReporter.m in Sources */, 34ADD2E01921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */, - AE31A2A119C0F23F00C438C1 /* CDRXTestSuite.m in Sources */, + AE31A2A119C0F23F00C438C1 /* CDRXCTestSuite.m in Sources */, AEEE1FF411DC27B800029872 /* CDRExample.m in Sources */, 34F3DF7F1A6ABA2E003041DA /* CDRNil.m in Sources */, AEEE1FF511DC27B800029872 /* CDRExampleBase.m in Sources */, + 3492DA971BA670C10032B35A /* CDRXCTestFunctions.m in Sources */, AEEE1FF611DC27B800029872 /* CDRExampleGroup.m in Sources */, AEEE1FF711DC27B800029872 /* CDRFunctions.m in Sources */, AEEE1FF811DC27B800029872 /* CDRSpec.m in Sources */, @@ -2925,7 +2930,7 @@ 96EA1CA8142C6425001A78E0 /* CDROTestReporter.m in Sources */, AE0C9D8E19C0C64200B4DD2B /* CDRSpec+XCTestSupport.m in Sources */, 34681C2C18FE451E009D38AC /* CDRTypeUtilities.m in Sources */, - 96EA1CAA142C6425001A78E0 /* CDROTestRunner.m in Sources */, + 96EA1CAA142C6425001A78E0 /* CDRTestBundleRunner.m in Sources */, 492951E01481AAFA00FA8916 /* CDRJUnitXMLReporter.m in Sources */, 6628FC9C14C4DEC50016652A /* CDRSpy.mm in Sources */, 34ADE41818F23C8E00BD1E99 /* NSMethodSignature+Cedar.m in Sources */, @@ -3048,6 +3053,7 @@ 1F483E34187D3CD200521F81 /* CDROTestNamer.m in Sources */, 4206446B139B44F600C85605 /* CDRTeamCityReporter.m in Sources */, 96EA1CA9142C6425001A78E0 /* CDROTestReporter.m in Sources */, + 3492DA981BA670C10032B35A /* CDRXCTestFunctions.m in Sources */, 34681C2E18FE4884009D38AC /* CDRTypeUtilities.m in Sources */, 1FE15C201869091900207F0C /* CDRReportDispatcher.m in Sources */, 960118BC1434867E00825FFF /* NSBundle+MainBundleHijack.m in Sources */, @@ -3065,13 +3071,13 @@ AE94D04615F3449500A0C2B7 /* AnyInstanceArgument.mm in Sources */, 1FF449B218A0C03900AF94B0 /* CDRBufferedDefaultReporter.m in Sources */, AE4A946218807DA6008566F5 /* RejectedMethod.mm in Sources */, - AE31A2A219C0F23F00C438C1 /* CDRXTestSuite.m in Sources */, + AE31A2A219C0F23F00C438C1 /* CDRXCTestSuite.m in Sources */, AEC7873A15F440980058A27B /* InvocationMatcher.mm in Sources */, AEC7874E15F444A50058A27B /* HaveReceived.mm in Sources */, 969B6F86160C678400C7C792 /* CDRSymbolicator.m in Sources */, E31179D6161FD937007D3CDE /* CDRSlowTestStatistics.m in Sources */, AE7F170B172730B000E1146D /* NSInvocation+Cedar.m in Sources */, - AEA8962C19D0C242007D5C08 /* CDROTestRunner.m in Sources */, + AEA8962C19D0C242007D5C08 /* CDRTestBundleRunner.m in Sources */, 34ADD2E11921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */, AE02021A17452007009A7915 /* StringifiersBase.mm in Sources */, AEE8DBD8175FFCF3008AF18A /* CDRSpyInfo.mm in Sources */, diff --git a/OS X Host AppTests/TestObservationHelper.m b/OS X Host AppTests/TestObservationHelper.m index 7a65e701..5317a22a 100644 --- a/OS X Host AppTests/TestObservationHelper.m +++ b/OS X Host AppTests/TestObservationHelper.m @@ -1,5 +1,5 @@ #import "TestObservationHelper.h" -#import "CDRXCTestObserver.h" +#import "CDRXCTestSupport.h" @interface XCTestSuite + (instancetype)defaultTestSuite; diff --git a/Source/CDROTestRunner.m b/Source/CDRTestBundleRunner.m similarity index 50% rename from Source/CDROTestRunner.m rename to Source/CDRTestBundleRunner.m index ea85ef72..68935766 100644 --- a/Source/CDROTestRunner.m +++ b/Source/CDRTestBundleRunner.m @@ -1,16 +1,16 @@ -#import "CDROTestRunner.h" +#import #import "CDRFunctions.h" -@interface CDROTestRunner () +@interface CDRTestBundleRunner : NSObject @end -@implementation CDROTestRunner +@implementation CDRTestBundleRunner + (void)load { if (!CDRGetTestBundleExtension()) { return; // we're not in a test bundle } - CDRInjectIntoXCTestRunner(); + CDRInjectIntoXCTestRunner(); } @end diff --git a/Source/Headers/Project/CDROTestRunner.h b/Source/Headers/Project/CDROTestRunner.h deleted file mode 100644 index a9d3e5a1..00000000 --- a/Source/Headers/Project/CDROTestRunner.h +++ /dev/null @@ -1,5 +0,0 @@ -#import - -@interface CDROTestRunner : NSObject - -@end diff --git a/Source/Headers/Project/CDRPrivateFunctions.h b/Source/Headers/Project/CDRPrivateFunctions.h index 79a53fa6..4b69590b 100644 --- a/Source/Headers/Project/CDRPrivateFunctions.h +++ b/Source/Headers/Project/CDRPrivateFunctions.h @@ -13,6 +13,7 @@ extern "C" { NSArray *CDRSpecClassesToRun(); NSArray *CDRRootGroupsFromSpecs(NSArray *specs); NSArray *CDRPermuteSpecClassesWithSeed(NSArray *unsortedSpecClasses, unsigned int seed); + id CDRCreateXCTestSuite(); #ifdef __cplusplus } diff --git a/Source/Headers/Project/XCTest/CDRXCTestCase.h b/Source/Headers/Project/XCTest/CDRXCTestCase.h index a0710c1c..01b60e2c 100644 --- a/Source/Headers/Project/XCTest/CDRXCTestCase.h +++ b/Source/Headers/Project/XCTest/CDRXCTestCase.h @@ -1,5 +1,7 @@ #import +/// The methods on this class are mixed into dynamically-created XCTestCase subclasses that +/// are created at runtime for each CDRSpec. @interface CDRXCTestCase : NSObject @end diff --git a/Source/Headers/Project/XCTest/CDRXCTestObserver.h b/Source/Headers/Project/XCTest/CDRXCTestObserver.h index ccdd3a1b..1a87c073 100644 --- a/Source/Headers/Project/XCTest/CDRXCTestObserver.h +++ b/Source/Headers/Project/XCTest/CDRXCTestObserver.h @@ -1,15 +1,5 @@ #import - -@class XCTestSuite; -@protocol XCTestObservation -@optional -- (void)testBundleDidFinish:(NSBundle *)testBundle; -@end - -@interface XCTestObservationCenter -+ (instancetype)sharedTestObservationCenter; -- (void)addTestObserver:(id)observer; -@end +#import "CDRXCTestSupport.h" @interface CDRXCTestObserver : NSObject @end diff --git a/Source/Headers/Project/XCTest/CDRXCTestSuite.h b/Source/Headers/Project/XCTest/CDRXCTestSuite.h new file mode 100644 index 00000000..a7ae3889 --- /dev/null +++ b/Source/Headers/Project/XCTest/CDRXCTestSuite.h @@ -0,0 +1,13 @@ +#import + +@class CDRReportDispatcher; + +/// This class should be thought of as a XCTestSuite subclass. The methods on this class are +/// copied onto a true XCTestSuite subclass created dynamically at runtime, allowing Cedar +/// to not need to link with XCTest +@interface CDRXCTestSuite : NSObject + +- (void)setDispatcher:(CDRReportDispatcher *)dispatcher; +- (CDRReportDispatcher *)dispatcher; + +@end diff --git a/Source/Headers/Project/XCTest/CDRXCTestSupport.h b/Source/Headers/Project/XCTest/CDRXCTestSupport.h new file mode 100644 index 00000000..2ad6ad8e --- /dev/null +++ b/Source/Headers/Project/XCTest/CDRXCTestSupport.h @@ -0,0 +1,29 @@ +#import + +// This file redeclares various XCTest classes and selectors to make the compiler happy. + +@class XCTestSuite; +@protocol XCTestObservation +@optional +- (void)testSuiteWillStart:(XCTestSuite *)testSuite; +@end + + +@interface CDRXCTestSupport + +// XCTest + +- (void)addTest:(id)test; +- (void)performTest:(id)aRun; + +// XCTestSuite + +- (id)defaultTestSuite; +- (id)CDR_original_defaultTestSuite; +- (id)initWithName:(NSString *)aName; + +// XCTestObservationCenter ++ (instancetype)sharedTestObservationCenter; +- (void)addTestObserver:(id)observer; + +@end diff --git a/Source/Headers/Project/XCTest/CDRXTestSuite.h b/Source/Headers/Project/XCTest/CDRXTestSuite.h deleted file mode 100644 index 5d10695e..00000000 --- a/Source/Headers/Project/XCTest/CDRXTestSuite.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@class CDRReportDispatcher; - -@interface CDRXTestSuite : NSObject - -- (void)setDispatcher:(CDRReportDispatcher *)dispatcher; -- (CDRReportDispatcher *)dispatcher; - -@end diff --git a/Source/XCTest/CDRXCTestFunctions.m b/Source/XCTest/CDRXCTestFunctions.m new file mode 100644 index 00000000..401fe5a3 --- /dev/null +++ b/Source/XCTest/CDRXCTestFunctions.m @@ -0,0 +1,83 @@ +#import +#import "CDRFunctions.h" +#import "CDRPrivateFunctions.h" +#import "CDRXCTestSuite.h" +#import "CDRRuntimeUtilities.h" +#import "CDRXCTestObserver.h" +#import "CDRReportDispatcher.h" +#import "CDRSpec.h" +#import + +void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { + unsigned int seed = CDRGetRandomSeed(); + + CDRDefineSharedExampleGroups(); + CDRDefineGlobalBeforeAndAfterEachBlocks(); + + NSArray *specClasses = CDRSpecClassesToRun(); + NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); + NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); + + CDRMarkFocusedExamplesInSpecs(specs); + CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); + + CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; + + NSArray *groups = CDRRootGroupsFromSpecs(specs); + [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; + + for (CDRSpec *spec in specs) { + [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; + } + + if ([testSuite respondsToSelector:@selector(setDispatcher:)]) { + [testSuite setDispatcher:dispatcher]; + } +} + +id CDRCreateXCTestSuite() { + Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); + Class testSuiteSubclass = NSClassFromString(@"_CDRXCTestSuite"); + + if (testSuiteSubclass == nil) { + size_t size = class_getInstanceSize([CDRXCTestSuite class]) - class_getInstanceSize([NSObject class]); + testSuiteSubclass = objc_allocateClassPair(testSuiteClass, "_CDRXCTestSuite", size); + CDRCopyClassInternalsFromClass([CDRXCTestSuite class], testSuiteSubclass); + objc_registerClassPair(testSuiteSubclass); + } + + id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; + + CDRAddCedarSpecsToXCTestSuite(testSuite); + + return testSuite; +} + +void CDRInjectIntoXCTestRunner() { + Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); + if (!testSuiteClass) { + [[NSException exceptionWithName:@"CedarNoTestFrameworkAvailable" reason:@"You must link against either the XCTest or SenTestingKit frameworks." userInfo:nil] raise]; + } + + // if possible, use the new XCTestObservation protocol available in Xcode 7 + Class observationCenterClass = NSClassFromString(@"XCTestObservationCenter"); + if (observationCenterClass && [observationCenterClass respondsToSelector:@selector(sharedTestObservationCenter)]) { + id observationCenter = [observationCenterClass sharedTestObservationCenter]; + static CDRXCTestObserver *xcTestObserver; + xcTestObserver = [[CDRXCTestObserver alloc] init]; + [observationCenter addTestObserver:xcTestObserver]; + + return; + } + + Class testSuiteMetaClass = object_getClass(testSuiteClass); + Method m = class_getClassMethod(testSuiteClass, @selector(defaultTestSuite)); + + class_addMethod(testSuiteMetaClass, @selector(CDR_original_defaultTestSuite), method_getImplementation(m), method_getTypeEncoding(m)); + IMP newImp = imp_implementationWithBlock(^id(id self){ + id defaultSuite = [self CDR_original_defaultTestSuite]; + [defaultSuite addTest:CDRCreateXCTestSuite()]; + return defaultSuite; + }); + class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); +} diff --git a/Source/XCTest/CDRXCTestObserver.m b/Source/XCTest/CDRXCTestObserver.m index 1cc81631..08604aa8 100644 --- a/Source/XCTest/CDRXCTestObserver.m +++ b/Source/XCTest/CDRXCTestObserver.m @@ -1,30 +1,9 @@ #import "CDRXCTestObserver.h" #import "CDRFunctions.h" #import "CDRPrivateFunctions.h" -#import "CDRReportDispatcher.h" -#import "CDRSpec.h" -#import - -#pragma mark - Running Test Bundles -#import "CDRXTestSuite.h" -#import "CDRRuntimeUtilities.h" - -static id CDRCreateXCTestSuite(); -static CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite); @interface CDRXCTestObserver () - @property (assign) BOOL observedTestSuiteStart; - -@end - -@interface CDRXCTestSupport : NSObject -- (id)defaultTestSuite; -- (id)initWithName:(NSString *)aName; - -- (id)CDR_original_defaultTestSuite; - -- (void)addTest:(id)test; @end @implementation CDRXCTestObserver @@ -40,79 +19,3 @@ - (void)testSuiteWillStart:(XCTestSuite *)testSuite { } @end - -static id CDRCreateXCTestSuite() { - Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); - Class testSuiteSubclass = NSClassFromString(@"_CDRXTestSuite"); - - if (testSuiteSubclass == nil) { - size_t size = class_getInstanceSize([CDRXTestSuite class]) - class_getInstanceSize([NSObject class]); - testSuiteSubclass = objc_allocateClassPair(testSuiteClass, "_CDRXTestSuite", size); - CDRCopyClassInternalsFromClass([CDRXTestSuite class], testSuiteSubclass); - objc_registerClassPair(testSuiteSubclass); - } - - id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; - - CDRAddCedarSpecsToXCTestSuite(testSuite); - - return testSuite; -} - -void CDRInjectIntoXCTestRunner() { - // if possible, use the new XCTestObservation protocol available in Xcode 7 - Class observationCenterClass = NSClassFromString(@"XCTestObservationCenter"); - if (observationCenterClass && [observationCenterClass respondsToSelector:@selector(sharedTestObservationCenter)]) { - id observationCenter = [observationCenterClass sharedTestObservationCenter]; - static CDRXCTestObserver *xcTestObserver; - xcTestObserver = [[CDRXCTestObserver alloc] init]; - [observationCenter addTestObserver:xcTestObserver]; - - return; - } - - Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); - if (!testSuiteClass) { - [[NSException exceptionWithName:@"CedarNoTestFrameworkAvailable" reason:@"You must link against either the XCTest or SenTestingKit frameworks." userInfo:nil] raise]; - } - - Class testSuiteMetaClass = object_getClass(testSuiteClass); - Method m = class_getClassMethod(testSuiteClass, @selector(defaultTestSuite)); - - class_addMethod(testSuiteMetaClass, @selector(CDR_original_defaultTestSuite), method_getImplementation(m), method_getTypeEncoding(m)); - IMP newImp = imp_implementationWithBlock(^id(id self){ - id defaultSuite = [self CDR_original_defaultTestSuite]; - [defaultSuite addTest:CDRCreateXCTestSuite()]; - return defaultSuite; - }); - class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m)); -} - -static CDRReportDispatcher *CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { - unsigned int seed = CDRGetRandomSeed(); - - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - - CDRMarkFocusedExamplesInSpecs(specs); - CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); - - CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; - - NSArray *groups = CDRRootGroupsFromSpecs(specs); - [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; - - for (CDRSpec *spec in specs) { - [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; - } - - if ([testSuite respondsToSelector:@selector(setDispatcher:)]) { - [testSuite setDispatcher:dispatcher]; - } - - return dispatcher; -} diff --git a/Source/XCTest/CDRXTestSuite.m b/Source/XCTest/CDRXCTestSuite.m similarity index 88% rename from Source/XCTest/CDRXTestSuite.m rename to Source/XCTest/CDRXCTestSuite.m index 176e0bd3..13594af5 100644 --- a/Source/XCTest/CDRXTestSuite.m +++ b/Source/XCTest/CDRXCTestSuite.m @@ -1,10 +1,11 @@ -#import "CDRXTestSuite.h" +#import "CDRXCTestSuite.h" #import "CDRReportDispatcher.h" +#import "CDRXCTestSupport.h" #import const char *CDRXDispatcherKey; -@implementation CDRXTestSuite +@implementation CDRXCTestSuite - (void)setDispatcher:(CDRReportDispatcher *)dispatcher { objc_setAssociatedObject(self, &CDRXDispatcherKey, dispatcher, OBJC_ASSOCIATION_RETAIN_NONATOMIC); diff --git a/Spec/iPhone/XCTest/CDRXTestSuiteSpec.mm b/Spec/iPhone/XCTest/CDRXTestSuiteSpec.mm index 3c5cdaee..28c14a80 100644 --- a/Spec/iPhone/XCTest/CDRXTestSuiteSpec.mm +++ b/Spec/iPhone/XCTest/CDRXTestSuiteSpec.mm @@ -8,19 +8,16 @@ #endif #import "CDRSpec.h" -#import "CDRXTestSuite.h" +#import "CDRXCTestSuite.h" #import "CDRReportDispatcher.h" - -@interface CDR_XCTest : NSObject -- (void)performTest:(id)aRun; -@end +#import "CDRXCTestSupport.h" using namespace Cedar::Matchers; using namespace Cedar::Doubles; -SPEC_BEGIN(CDRXTestSuiteSpec) +SPEC_BEGIN(CDRXCTestSuiteSpec) -describe(@"CDRXTestSuite", ^{ +describe(@"CDRXCTestSuite", ^{ __block id subject; __block CDRReportDispatcher *dispatcher; From ea81decadd223cf4cfa0a2fa93f0680c3a0df806 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 14 Sep 2015 10:54:33 -0400 Subject: [PATCH 16/21] Reduce code duplication between running test suites and test bundles --- Cedar.xcodeproj/project.pbxproj | 16 ++++++ Source/CDRFunctions.m | 34 +++---------- Source/CDRRuntimeUtilities.m | 13 +++++ Source/CDRSpecRun.m | 44 ++++++++++++++++ Source/Headers/Project/CDRRuntimeUtilities.h | 6 ++- Source/Headers/Project/CDRSpecRun.h | 15 ++++++ .../Headers/Project/XCTest/CDRXCTestSuite.h | 5 +- Source/XCTest/CDRSpec+XCTestSupport.m | 16 ++---- Source/XCTest/CDRXCTestFunctions.m | 42 +++------------- Source/XCTest/CDRXCTestSuite.m | 50 +++++++++++++++---- 10 files changed, 149 insertions(+), 92 deletions(-) create mode 100644 Source/CDRSpecRun.m create mode 100644 Source/Headers/Project/CDRSpecRun.h diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index 977b8a1d..d1ae6d1b 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -87,6 +87,12 @@ 3492DA991BA670C10032B35A /* CDRXCTestFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */; }; 3492DA9B1BA672AB0032B35A /* CDRXCTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */; }; 3492DA9C1BA672AD0032B35A /* CDRXCTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */; }; + 3492DA9F1BA6F9E70032B35A /* CDRSpecRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9D1BA6F9E70032B35A /* CDRSpecRun.h */; }; + 3492DAA01BA6F9E70032B35A /* CDRSpecRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9D1BA6F9E70032B35A /* CDRSpecRun.h */; }; + 3492DAA11BA6F9E70032B35A /* CDRSpecRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 3492DA9D1BA6F9E70032B35A /* CDRSpecRun.h */; }; + 3492DAA21BA6F9E70032B35A /* CDRSpecRun.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA9E1BA6F9E70032B35A /* CDRSpecRun.m */; }; + 3492DAA31BA6F9E70032B35A /* CDRSpecRun.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA9E1BA6F9E70032B35A /* CDRSpecRun.m */; }; + 3492DAA41BA6F9E70032B35A /* CDRSpecRun.m in Sources */ = {isa = PBXBuildFile; fileRef = 3492DA9E1BA6F9E70032B35A /* CDRSpecRun.m */; }; 34ADD2E01921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E11921F18100B057AC /* AnyInstanceOfClassArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */; }; 34ADD2E71921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ADD2E51921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm */; }; @@ -880,6 +886,8 @@ 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRPrivateFunctions.h; sourceTree = ""; }; 3492DA961BA670C10032B35A /* CDRXCTestFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRXCTestFunctions.m; sourceTree = ""; }; 3492DA9A1BA672A60032B35A /* CDRXCTestSupport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDRXCTestSupport.h; sourceTree = ""; }; + 3492DA9D1BA6F9E70032B35A /* CDRSpecRun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDRSpecRun.h; sourceTree = ""; }; + 3492DA9E1BA6F9E70032B35A /* CDRSpecRun.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDRSpecRun.m; sourceTree = ""; }; 34ADD2DD1921F0B500B057AC /* AnyInstanceOfClassArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceOfClassArgument.h; sourceTree = ""; }; 34ADD2DE1921F18100B057AC /* AnyInstanceOfClassArgument.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AnyInstanceOfClassArgument.mm; sourceTree = ""; }; 34ADD2E41921F2F600B057AC /* AnyInstanceConformingToProtocolArgument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnyInstanceConformingToProtocolArgument.h; sourceTree = ""; }; @@ -1350,6 +1358,7 @@ 34F3DF7B1A6ABA2E003041DA /* CDRNil.h */, 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */, AE55BF1D19A7CF83005948E6 /* CDRRuntimeUtilities.h */, + 3492DA9D1BA6F9E70032B35A /* CDRSpecRun.h */, 969B6F95160F1FEC00C7C792 /* CDRSymbolicator.h */, 34681C2D18FE4611009D38AC /* CDRTypeUtilities.h */, ); @@ -1844,6 +1853,7 @@ 969B6F82160C61E000C7C792 /* CDRSymbolicator.m */, 34681C2B18FE451E009D38AC /* CDRTypeUtilities.m */, 34F3DF7C1A6ABA2E003041DA /* CDRNil.m */, + 3492DA9E1BA6F9E70032B35A /* CDRSpecRun.m */, ); path = Source; sourceTree = ""; @@ -2095,6 +2105,7 @@ AE4865B61B0690B0005DB302 /* CedarApplicationDelegate.h in Headers */, AE4865B71B0690B0005DB302 /* Cedar-iOS.h in Headers */, AE4865B81B0690B0005DB302 /* Base.h in Headers */, + 3492DAA11BA6F9E70032B35A /* CDRSpecRun.h in Headers */, AE4865B91B0690B0005DB302 /* BeCloseTo.h in Headers */, AE4865BA1B0690B0005DB302 /* BeFalsy.h in Headers */, AE4865BB1B0690B0005DB302 /* BeGreaterThan.h in Headers */, @@ -2178,6 +2189,7 @@ AEEE1FFB11DC27B800029872 /* CDRExampleBase.h in Headers */, AEEE1FFD11DC27B800029872 /* CDRExampleParent.h in Headers */, AEEE1FFE11DC27B800029872 /* CDRExampleReporter.h in Headers */, + 3492DA9F1BA6F9E70032B35A /* CDRSpecRun.h in Headers */, AEEE1FFF11DC27B800029872 /* CDRFunctions.h in Headers */, AEEE200011DC27B800029872 /* CDRSpec.h in Headers */, AEEE200111DC27B800029872 /* Cedar.h in Headers */, @@ -2270,6 +2282,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 3492DAA01BA6F9E70032B35A /* CDRSpecRun.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2884,6 +2897,7 @@ AE48658A1B067954005DB302 /* CDROTestNamer.m in Sources */, AE48658B1B067954005DB302 /* CDRSlowTestStatistics.m in Sources */, AE48658C1B067954005DB302 /* CDRColorizedReporter.m in Sources */, + 3492DAA41BA6F9E70032B35A /* CDRSpecRun.m in Sources */, AE48658D1B067954005DB302 /* CDRDefaultReporter.m in Sources */, AE48658E1B067954005DB302 /* CDRJUnitXMLReporter.m in Sources */, AE48658F1B067954005DB302 /* CDROTestReporter.m in Sources */, @@ -2918,6 +2932,7 @@ 34F3DF7F1A6ABA2E003041DA /* CDRNil.m in Sources */, AEEE1FF511DC27B800029872 /* CDRExampleBase.m in Sources */, 3492DA971BA670C10032B35A /* CDRXCTestFunctions.m in Sources */, + 3492DAA21BA6F9E70032B35A /* CDRSpecRun.m in Sources */, AEEE1FF611DC27B800029872 /* CDRExampleGroup.m in Sources */, AEEE1FF711DC27B800029872 /* CDRFunctions.m in Sources */, AEEE1FF811DC27B800029872 /* CDRSpec.m in Sources */, @@ -3064,6 +3079,7 @@ AE167EF315B216DA005960B9 /* RaiseException.mm in Sources */, 34ADD2E81921F33800B057AC /* AnyInstanceConformingToProtocolArgument.mm in Sources */, AE74907215B486CD008EA127 /* CDRFake.mm in Sources */, + 3492DAA31BA6F9E70032B35A /* CDRSpecRun.m in Sources */, AE74907715B493C4008EA127 /* CDRProtocolFake.mm in Sources */, AE36AC6615B5CA6E00EB6C51 /* CedarDouble.mm in Sources */, 34ADE41918F23E6B00BD1E99 /* NSMethodSignature+Cedar.m in Sources */, diff --git a/Source/CDRFunctions.m b/Source/CDRFunctions.m index 1d542c0d..b1b3ff56 100644 --- a/Source/CDRFunctions.m +++ b/Source/CDRFunctions.m @@ -9,6 +9,7 @@ #import "CDRReportDispatcher.h" #import "CDROTestNamer.h" #import "CDRVersion.h" +#import "CDRSpecRun.h" static NSString * const CDRBuildVersionKey = @"CDRBuildVersionSHA"; @@ -270,14 +271,6 @@ void CDRMarkXcodeFocusedExamplesInSpecs(NSArray *specs, NSArray *arguments) { } } -NSArray *CDRRootGroupsFromSpecs(NSArray *specs) { - NSMutableArray *groups = [NSMutableArray arrayWithCapacity:specs.count]; - for (CDRSpec *spec in specs) { - [groups addObject:spec.rootGroup]; - } - return groups; -} - NSArray *CDRShuffleItemsInArrayWithSeed(NSArray *sortedItems, unsigned int seed) { NSMutableArray *shuffledItems = [sortedItems mutableCopy]; srand(seed); @@ -312,28 +305,13 @@ void __attribute__((weak)) __gcov_flush(void) { int CDRRunSpecsWithCustomExampleReporters(NSArray *reporters) { @autoreleasepool { - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - unsigned int seed = CDRGetRandomSeed(); - - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - CDRMarkFocusedExamplesInSpecs(specs); - CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); - - CDRReportDispatcher *dispatcher = [[CDRReportDispatcher alloc] initWithReporters:reporters]; - - NSArray *groups = CDRRootGroupsFromSpecs(specs); - [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; - - [groups makeObjectsPerformSelector:@selector(runWithDispatcher:) withObject:dispatcher]; + CDRSpecRun *run = [[CDRSpecRun alloc] initWithExampleReporters:reporters]; - [dispatcher runDidComplete]; - int result = [dispatcher result]; + int result = [run performSpecRun:^{ + [run.rootGroups makeObjectsPerformSelector:@selector(runWithDispatcher:) withObject:run.dispatcher]; + }]; - [dispatcher release]; + [run release]; __gcov_flush(); diff --git a/Source/CDRRuntimeUtilities.m b/Source/CDRRuntimeUtilities.m index 85fae501..c62c6ae6 100644 --- a/Source/CDRRuntimeUtilities.m +++ b/Source/CDRRuntimeUtilities.m @@ -76,3 +76,16 @@ void CDRCopyClassInternalsFromClass(Class sourceClass, Class destinationClass) { CDRCopyClassMethodsFromClass(sourceClass, destinationClass); } +@implementation CDRRuntimeUtilities + ++ (Class)createMixinSubclassOf:(Class)parentClass newClassName:(NSString *)newClassName templateClass:(Class)templateClass { + size_t size = class_getInstanceSize(templateClass) - class_getInstanceSize([NSObject class]); + Class newSubclass = objc_allocateClassPair(parentClass, [newClassName UTF8String], size); + + CDRCopyClassInternalsFromClass(templateClass, newSubclass); + objc_registerClassPair(newSubclass); + + return newSubclass; +} + +@end diff --git a/Source/CDRSpecRun.m b/Source/CDRSpecRun.m new file mode 100644 index 00000000..544be678 --- /dev/null +++ b/Source/CDRSpecRun.m @@ -0,0 +1,44 @@ +#import "CDRSpecRun.h" +#import "CDRSpec.h" +#import "CDRPrivateFunctions.h" +#import "CDRReportDispatcher.h" + +@implementation CDRSpecRun + +- (instancetype)initWithExampleReporters:(NSArray *)reporters { + if (self = [super init]) { + CDRDefineSharedExampleGroups(); + CDRDefineGlobalBeforeAndAfterEachBlocks(); + + _seed = CDRGetRandomSeed(); + + NSArray *specClasses = CDRSpecClassesToRun(); + NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, _seed); + _specs = [CDRSpecsFromSpecClasses(permutedSpecClasses) retain]; + CDRMarkFocusedExamplesInSpecs(_specs); + CDRMarkXcodeFocusedExamplesInSpecs(_specs, [[NSProcessInfo processInfo] arguments]); + + _dispatcher = [[CDRReportDispatcher alloc] initWithReporters:reporters]; + _rootGroups = [[_specs valueForKey:NSStringFromSelector(@selector(rootGroup))] retain]; + } + return self; +} + +- (void)dealloc { + [_specs release]; _specs = nil; + [_rootGroups release]; _rootGroups = nil; + [_dispatcher release]; _dispatcher = nil; + [super dealloc]; +} + +- (int)performSpecRun:(void (^)(void))runBlock { + [self.dispatcher runWillStartWithGroups:self.rootGroups andRandomSeed:self.seed]; + + runBlock(); + + [self.dispatcher runDidComplete]; + + return [self.dispatcher result]; +} + +@end diff --git a/Source/Headers/Project/CDRRuntimeUtilities.h b/Source/Headers/Project/CDRRuntimeUtilities.h index b3cdcd3b..25428fd9 100644 --- a/Source/Headers/Project/CDRRuntimeUtilities.h +++ b/Source/Headers/Project/CDRRuntimeUtilities.h @@ -1,3 +1,7 @@ #import -extern void CDRCopyClassInternalsFromClass(Class sourceClass, Class destinationClass); +@interface CDRRuntimeUtilities : NSObject + ++ (Class)createMixinSubclassOf:(Class)parentClass newClassName:(NSString *)newClassName templateClass:(Class)templateClass; + +@end diff --git a/Source/Headers/Project/CDRSpecRun.h b/Source/Headers/Project/CDRSpecRun.h new file mode 100644 index 00000000..78c0116c --- /dev/null +++ b/Source/Headers/Project/CDRSpecRun.h @@ -0,0 +1,15 @@ +#import + +@class CDRReportDispatcher; + +@interface CDRSpecRun : NSObject + +@property (nonatomic, retain, readonly) NSArray *specs; +@property (nonatomic, retain, readonly) NSArray *rootGroups; +@property (nonatomic, retain, readonly) CDRReportDispatcher *dispatcher; +@property (nonatomic, assign, readonly) unsigned int seed; + +- (instancetype)initWithExampleReporters:(NSArray *)reporters; +- (int)performSpecRun:(void (^)(void))runBlock; + +@end diff --git a/Source/Headers/Project/XCTest/CDRXCTestSuite.h b/Source/Headers/Project/XCTest/CDRXCTestSuite.h index a7ae3889..6bfcbdad 100644 --- a/Source/Headers/Project/XCTest/CDRXCTestSuite.h +++ b/Source/Headers/Project/XCTest/CDRXCTestSuite.h @@ -1,13 +1,12 @@ #import -@class CDRReportDispatcher; +@class CDRSpecRun; /// This class should be thought of as a XCTestSuite subclass. The methods on this class are /// copied onto a true XCTestSuite subclass created dynamically at runtime, allowing Cedar /// to not need to link with XCTest @interface CDRXCTestSuite : NSObject -- (void)setDispatcher:(CDRReportDispatcher *)dispatcher; -- (CDRReportDispatcher *)dispatcher; +- (instancetype)initWithSpecRun:(CDRSpecRun *)specRun; @end diff --git a/Source/XCTest/CDRSpec+XCTestSupport.m b/Source/XCTest/CDRSpec+XCTestSupport.m index 2f9fe50a..07b353c9 100644 --- a/Source/XCTest/CDRSpec+XCTestSupport.m +++ b/Source/XCTest/CDRSpec+XCTestSupport.m @@ -86,9 +86,9 @@ - (Class)createTestCaseSubclass { NSString *newClassName = [NSString stringWithFormat:@"_%@", className]; Class newXCTestSubclass = NSClassFromString(newClassName); if (!newXCTestSubclass) { - newXCTestSubclass = [self createMixinSubclassOf:testCaseClass - newClassName:newClassName - templateClass:[CDRXCTestCase class]]; + newXCTestSubclass = [CDRRuntimeUtilities createMixinSubclassOf:testCaseClass + newClassName:newClassName + templateClass:[CDRXCTestCase class]]; } return newXCTestSubclass; @@ -109,16 +109,6 @@ - (NSArray *)allExamplesToRun { return examples; } -- (Class)createMixinSubclassOf:(Class)parentClass newClassName:(NSString *)newClassName templateClass:(Class)templateClass { - size_t size = class_getInstanceSize(templateClass) - class_getInstanceSize([NSObject class]); - Class newSubclass = objc_allocateClassPair(parentClass, [newClassName UTF8String], size); - - CDRCopyClassInternalsFromClass(templateClass, newSubclass); - objc_registerClassPair(newSubclass); - - return newSubclass; -} - - (void)createTestMethodForSelector:(SEL)selector onClass:(Class)aClass { IMP imp = imp_implementationWithBlock(^(id instance){ CDRExample *example = [[instance invocation] cdr_example]; diff --git a/Source/XCTest/CDRXCTestFunctions.m b/Source/XCTest/CDRXCTestFunctions.m index 401fe5a3..e5188cab 100644 --- a/Source/XCTest/CDRXCTestFunctions.m +++ b/Source/XCTest/CDRXCTestFunctions.m @@ -6,51 +6,21 @@ #import "CDRXCTestObserver.h" #import "CDRReportDispatcher.h" #import "CDRSpec.h" +#import "CDRSpecRun.h" #import -void CDRAddCedarSpecsToXCTestSuite(XCTestSuite *testSuite) { - unsigned int seed = CDRGetRandomSeed(); - - CDRDefineSharedExampleGroups(); - CDRDefineGlobalBeforeAndAfterEachBlocks(); - - NSArray *specClasses = CDRSpecClassesToRun(); - NSArray *permutedSpecClasses = CDRPermuteSpecClassesWithSeed(specClasses, seed); - NSArray *specs = CDRSpecsFromSpecClasses(permutedSpecClasses); - - CDRMarkFocusedExamplesInSpecs(specs); - CDRMarkXcodeFocusedExamplesInSpecs(specs, [[NSProcessInfo processInfo] arguments]); - - CDRReportDispatcher *dispatcher = [[[CDRReportDispatcher alloc] initWithReporters:CDRReportersToRun()] autorelease]; - - NSArray *groups = CDRRootGroupsFromSpecs(specs); - [dispatcher runWillStartWithGroups:groups andRandomSeed:seed]; - - for (CDRSpec *spec in specs) { - [testSuite addTest:[spec testSuiteWithRandomSeed:seed dispatcher:dispatcher]]; - } - - if ([testSuite respondsToSelector:@selector(setDispatcher:)]) { - [testSuite setDispatcher:dispatcher]; - } -} - id CDRCreateXCTestSuite() { Class testSuiteClass = NSClassFromString(@"XCTestSuite") ?: NSClassFromString(@"SenTestSuite"); Class testSuiteSubclass = NSClassFromString(@"_CDRXCTestSuite"); if (testSuiteSubclass == nil) { - size_t size = class_getInstanceSize([CDRXCTestSuite class]) - class_getInstanceSize([NSObject class]); - testSuiteSubclass = objc_allocateClassPair(testSuiteClass, "_CDRXCTestSuite", size); - CDRCopyClassInternalsFromClass([CDRXCTestSuite class], testSuiteSubclass); - objc_registerClassPair(testSuiteSubclass); + testSuiteSubclass = [CDRRuntimeUtilities createMixinSubclassOf:testSuiteClass + newClassName:@"_CDRXCTestSuite" + templateClass:[CDRXCTestSuite class]]; } - id testSuite = [[[(id)testSuiteSubclass alloc] initWithName:@"Cedar"] autorelease]; - - CDRAddCedarSpecsToXCTestSuite(testSuite); - - return testSuite; + CDRSpecRun *run = [[[CDRSpecRun alloc] initWithExampleReporters:CDRReportersToRun()] autorelease]; + return [[[testSuiteSubclass alloc] initWithSpecRun:run] autorelease]; } void CDRInjectIntoXCTestRunner() { diff --git a/Source/XCTest/CDRXCTestSuite.m b/Source/XCTest/CDRXCTestSuite.m index 13594af5..70cfcfc6 100644 --- a/Source/XCTest/CDRXCTestSuite.m +++ b/Source/XCTest/CDRXCTestSuite.m @@ -1,26 +1,54 @@ #import "CDRXCTestSuite.h" -#import "CDRReportDispatcher.h" +#import "CDRSpecRun.h" +#import "CDRSpec.h" #import "CDRXCTestSupport.h" #import -const char *CDRXDispatcherKey; +const char *CDRSpecRunKey; + +@interface CDRXCTestSuite (FromXCTest) +- (instancetype)initWithName:(NSString *)name; +- (void)addTest:(id)test; +@end + +@interface CDRXCTestSuite () +@property (nonatomic, retain) CDRSpecRun *specRun; +@end @implementation CDRXCTestSuite -- (void)setDispatcher:(CDRReportDispatcher *)dispatcher { - objc_setAssociatedObject(self, &CDRXDispatcherKey, dispatcher, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} +- (instancetype)initWithSpecRun:(CDRSpecRun *)specRun { + if (self = [self initWithName:@"Cedar"]) { + self.specRun = specRun; -- (CDRReportDispatcher *)dispatcher { - return objc_getAssociatedObject(self, &CDRXDispatcherKey); + for (CDRSpec *spec in specRun.specs) { + [self addTest:[spec testSuiteWithRandomSeed:specRun.seed dispatcher:specRun.dispatcher]]; + } + } + return self; } +/// This is needed to allow for runtime lookup of the superclass +#define super_performTest(RUN) do { \ +Class parentClass = class_getSuperclass([self class]); \ +IMP superPerformTest = class_getMethodImplementation(parentClass, @selector(performTest:)); \ +((void (*)(id instance, SEL cmd, id run))superPerformTest)(self, _cmd, RUN); \ +} while(0); + - (void)performTest:(id)aRun { - Class parentClass = class_getSuperclass([self class]); - IMP superPerformTest = class_getMethodImplementation(parentClass, @selector(performTest:)); - ((void (*)(id instance, SEL cmd, id run))superPerformTest)(self, _cmd, aRun); + [self.specRun performSpecRun:^{ + super_performTest(aRun); + }]; +} + +#pragma mark - Accessors + +- (void)setSpecRun:(CDRSpecRun *)specRun { + objc_setAssociatedObject(self, &CDRSpecRunKey, specRun, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} - [[self dispatcher] runDidComplete]; +- (CDRSpecRun *)specRun { + return objc_getAssociatedObject(self, &CDRSpecRunKey); } @end From 59a765041b83a1a6135b18d3c603fc696eaa8845 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 14 Sep 2015 11:39:27 -0400 Subject: [PATCH 17/21] =?UTF-8?q?Don=E2=80=99t=20use=20methods=20not=20ava?= =?UTF-8?q?ilable=20on=20iOS=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CDRSymbolicator.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CDRSymbolicator.m b/Source/CDRSymbolicator.m index ffe1ebc9..a72d7154 100644 --- a/Source/CDRSymbolicator.m +++ b/Source/CDRSymbolicator.m @@ -307,8 +307,8 @@ + (CDRAtosTask *)taskForCurrentTestExecutable { } + (BOOL)isImagePathATestBundle:(NSString *)imageName { - BOOL isOCTestBundle = [imageName containsString:@".octest/"]; - BOOL isXCTestBundle = [imageName containsString:@".xctest/"]; + BOOL isOCTestBundle = [imageName rangeOfString:@".octest/"].location != NSNotFound; + BOOL isXCTestBundle = [imageName rangeOfString:@".xctest/"].location != NSNotFound; return isOCTestBundle || isXCTestBundle; } From 6f4dd0512a0dd1a8098a7e1d6442349940681c13 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 14 Sep 2015 14:21:57 -0400 Subject: [PATCH 18/21] Reintroduce an iOS test bundle spec --- Cedar.xcodeproj/project.pbxproj | 2 ++ XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Cedar.xcodeproj/project.pbxproj b/Cedar.xcodeproj/project.pbxproj index d1ae6d1b..0321e72e 100644 --- a/Cedar.xcodeproj/project.pbxproj +++ b/Cedar.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 34322B091BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; 34322B0A1BA740B900D0CFBD /* CDRXCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 34322B081BA740B900D0CFBD /* CDRXCTestObserver.h */; settings = {ASSET_TAGS = (); }; }; 34322B0B1BA742B400D0CFBD /* CDRPrivateFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 34777EB61B99451200A69FCF /* CDRPrivateFunctions.h */; settings = {ASSET_TAGS = (); }; }; + 34322B0C1BA7471B00D0CFBD /* TestObservationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34757E211BA466050047BC8D /* TestObservationHelper.m */; settings = {ASSET_TAGS = (); COMPILER_FLAGS = "-fobjc-arc"; }; }; 343FAFEA190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 343FAFEB190FDAEC0085AFEC /* DeallocNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 343FAFE9190FDAEC0085AFEC /* DeallocNotifier.m */; }; 34640DA71B6964F90083EB01 /* CDRBlockHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 3460489318F2DBBF00BC93B6 /* CDRBlockHelper.h */; }; @@ -2731,6 +2732,7 @@ AE34723919C12588005CA6F1 /* SimpleKeyValueObserver.m in Sources */, F78FDA1B1B43AB540054C768 /* SimpleIncrementer.m in Sources */, AE34723419C124D6005CA6F1 /* ObjCHeadersSpec.mm in Sources */, + 34322B0C1BA7471B00D0CFBD /* TestObservationHelper.m in Sources */, AE34723D19C22547005CA6F1 /* CDRDefaultReporterSpec.mm in Sources */, AE34724619C225A1005CA6F1 /* CDRXTestSuiteSpec.mm in Sources */, F78FDA1A1B43AA930054C768 /* HaveReceivedSpec.mm in Sources */, diff --git a/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m b/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m index b5b845d0..f2799a62 100644 --- a/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m +++ b/XCUnitAppTests/XCUnitApplicationTestsWithXCTest.m @@ -1,5 +1,6 @@ #import #import "OCUnitAppAppDelegate.h" // should NOT be included in OCUnitAppTests target +#import "TestObservationHelper.h" @interface ExampleApplicationTestsWithXCTest : XCTestCase @end @@ -24,4 +25,9 @@ - (void)testCanLoadNibFilesFromApp { XCTAssertEqual([[views lastObject] class], [UIView class], @"expected last view of DummyView nib to be UIView kind"); } +- (void)testRunningCedarExamples { + NSArray *knownTestSuites = [TestObservationHelper knownTestSuites]; + XCTAssert([[knownTestSuites valueForKeyPath:@"@unionOfArrays.tests.name"] containsObject:@"Cedar"]); +} + @end From fdd2f660319f6cf5dda49209d00285bcacad65a0 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 14 Sep 2015 14:22:47 -0400 Subject: [PATCH 19/21] Remove the Xcode 7 note in the README --- README.markdown | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.markdown b/README.markdown index d9821089..ecf63cbb 100644 --- a/README.markdown +++ b/README.markdown @@ -27,12 +27,6 @@ describe(@"Example specs on NSString", ^{ }); ``` -## Note for Xcode 7 users - -With Xcode 7, Apple has introduced changes to `XCTest.framework` which are incompatible with Cedar's test bundle -runner. (See [#333](https://github.com/pivotal/cedar/issues/333) for more details.) Support for Xcode 7 is -being actively developed on the `Xcode7` [branch](https://github.com/pivotal/cedar/tree/Xcode7) which should be -used until we feel that the Xcode 7 betas have stabilized and we are ready to merge this work into the `master` branch. # Quick start From d54eece9be072959c7595aec69421d1611b62420 Mon Sep 17 00:00:00 2001 From: Brian Croom Date: Mon, 14 Sep 2015 14:35:04 -0400 Subject: [PATCH 20/21] Fix warning about SCRCException when bootstrapping Cedar --- Source/CDRFunctions.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/CDRFunctions.m b/Source/CDRFunctions.m index b1b3ff56..ac15c3bd 100644 --- a/Source/CDRFunctions.m +++ b/Source/CDRFunctions.m @@ -78,7 +78,9 @@ void CDRDefineSharedExampleGroups() { } BOOL CDRClassHasClassMethod(Class class, SEL selector) { - if (strcmp("UIAccessibilitySafeCategory__NSObject", class_getName(class))) { + const char *className = class_getName(class); + if (strcmp("UIAccessibilitySafeCategory__NSObject", className) && + strcmp("SCRCException", className)) { return !!class_getClassMethod(class, selector); } return NO; From 94e8a8d9908b0f4329a6cffe28a320a0028b9ed4 Mon Sep 17 00:00:00 2001 From: Priyanka Ranjan Date: Mon, 14 Sep 2015 15:29:21 -0400 Subject: [PATCH 21/21] Update podspec to produce the DEVELOPER_BIN_DIR preprocessor macro --- Cedar.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cedar.podspec b/Cedar.podspec index a0457b31..f6a547ac 100644 --- a/Cedar.podspec +++ b/Cedar.podspec @@ -19,7 +19,8 @@ Pod::Spec.new do |s| # https://github.com/pivotal/cedar/issues/47 s.xcconfig = { 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++0x', - 'CLANG_CXX_LIBRARY' => 'libc++' + 'CLANG_CXX_LIBRARY' => 'libc++', + 'OTHER_CFLAGS' => '-DDEVELOPER_BIN_DIR=@\"${DEVELOPER_BIN_DIR}\"' } s.libraries = 'c++' s.requires_arc = false