Skip to content

Commit 173c515

Browse files
authored
Fixes intermittent test failures (#1523)
* Handles the async action in Parse initialize. Fires a notification when it's done. * Removes failing TwitterUtils test * Fixes a timing issue * Improves reliability of testFetchPin * Adds OCMock as a dependency to our test targets. Fixes the ominous build warning. * Removes call to OCMock stopMocking in PFTestCase It's generally advised in the OCMock docs not to call it. Tests don't seem to break if we don't have it, so it appears we don't need to call it. * Re-adds testRotation but skips. So we remember it.
1 parent 1ede703 commit 173c515

File tree

12 files changed

+194
-37
lines changed

12 files changed

+194
-37
lines changed

Carthage/Checkouts/OCMock

Submodule OCMock updated 54 files

Parse/Parse.xcodeproj/project.pbxproj

Lines changed: 144 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,8 +2639,6 @@
26392639
B141170F1E5D081500F70D7A /* PFFileUploadResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B141170A1E5D081500F70D7A /* PFFileUploadResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
26402640
B14117101E5D081500F70D7A /* PFFileUploadResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B141170A1E5D081500F70D7A /* PFFileUploadResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
26412641
B14117111E5D081500F70D7A /* PFFileUploadResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B141170A1E5D081500F70D7A /* PFFileUploadResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
2642-
B9312D5B23C4A6FC002D4A4C /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9312D5623C4A6FC002D4A4C /* OCMock.framework */; };
2643-
B9312D5D23C4A775002D4A4C /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9312D5C23C4A775002D4A4C /* OCMock.framework */; };
26442642
BC5511D6242E6E66008E5D9F /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCC5EAAC22D5F96600CF8900 /* Bolts.framework */; };
26452643
BCC5EAB322D5F97E00CF8900 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCC5EAB222D5F97D00CF8900 /* Bolts.framework */; };
26462644
BCC5EAB522D5F98F00CF8900 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCC5EAB422D5F98F00CF8900 /* Bolts.framework */; };
@@ -2927,6 +2925,69 @@
29272925
remoteGlobalIDString = 81C3821B19CCA89E0066284A;
29282926
remoteInfo = "Parse-iOS";
29292927
};
2928+
BC105FC424C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2929+
isa = PBXContainerItemProxy;
2930+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2931+
proxyType = 2;
2932+
remoteGlobalIDString = 030EF0A814632FD000B04273;
2933+
remoteInfo = OCMock;
2934+
};
2935+
BC105FC624C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2936+
isa = PBXContainerItemProxy;
2937+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2938+
proxyType = 2;
2939+
remoteGlobalIDString = 03565A3118F0566E003AE91E;
2940+
remoteInfo = OCMockTests;
2941+
};
2942+
BC105FC824C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2943+
isa = PBXContainerItemProxy;
2944+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2945+
proxyType = 2;
2946+
remoteGlobalIDString = 030EF0DC14632FF700B04273;
2947+
remoteInfo = OCMockLib;
2948+
};
2949+
BC105FCA24C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2950+
isa = PBXContainerItemProxy;
2951+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2952+
proxyType = 2;
2953+
remoteGlobalIDString = D31108AD1828DB8700737925;
2954+
remoteInfo = OCMockLibTests;
2955+
};
2956+
BC105FCC24C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2957+
isa = PBXContainerItemProxy;
2958+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2959+
proxyType = 2;
2960+
remoteGlobalIDString = F0B950F11B0080BE00942C38;
2961+
remoteInfo = "OCMock iOS";
2962+
};
2963+
BC105FCE24C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2964+
isa = PBXContainerItemProxy;
2965+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2966+
proxyType = 2;
2967+
remoteGlobalIDString = 817EB1621BD765130047E85A;
2968+
remoteInfo = "OCMock tvOS";
2969+
};
2970+
BC105FD024C5D0C900295EF7 /* PBXContainerItemProxy */ = {
2971+
isa = PBXContainerItemProxy;
2972+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2973+
proxyType = 2;
2974+
remoteGlobalIDString = 8DE97CA022B43EE60098C63F;
2975+
remoteInfo = "OCMock watchOS";
2976+
};
2977+
BC105FD224C5D0D600295EF7 /* PBXContainerItemProxy */ = {
2978+
isa = PBXContainerItemProxy;
2979+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2980+
proxyType = 1;
2981+
remoteGlobalIDString = 030EF0A714632FD000B04273;
2982+
remoteInfo = OCMock;
2983+
};
2984+
BC105FD424C5D0E100295EF7 /* PBXContainerItemProxy */ = {
2985+
isa = PBXContainerItemProxy;
2986+
containerPortal = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
2987+
proxyType = 1;
2988+
remoteGlobalIDString = F0B950F01B0080BE00942C38;
2989+
remoteInfo = "OCMock iOS";
2990+
};
29302991
/* End PBXContainerItemProxy section */
29312992

29322993
/* Begin PBXCopyFilesBuildPhase section */
@@ -3482,8 +3543,7 @@
34823543
B141169D1E5BC24B00F70D7A /* PFFileUploadController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFFileUploadController.h; sourceTree = "<group>"; };
34833544
B14116FB1E5D078E00F70D7A /* PFFileUploadResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PFFileUploadResult.m; sourceTree = "<group>"; };
34843545
B141170A1E5D081500F70D7A /* PFFileUploadResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PFFileUploadResult.h; sourceTree = "<group>"; };
3485-
B9312D5623C4A6FC002D4A4C /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCMock.framework; path = ../Carthage/Build/iOS/OCMock.framework; sourceTree = "<group>"; };
3486-
B9312D5C23C4A775002D4A4C /* OCMock.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OCMock.framework; path = ../Carthage/Build/Mac/OCMock.framework; sourceTree = "<group>"; };
3546+
BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OCMock.xcodeproj; path = ../Carthage/Checkouts/OCMock/Source/OCMock.xcodeproj; sourceTree = "<group>"; };
34873547
BCC5EAAC22D5F96600CF8900 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = ../Carthage/Build/iOS/Bolts.framework; sourceTree = "<group>"; };
34883548
BCC5EAB222D5F97D00CF8900 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = ../Carthage/Build/tvOS/Bolts.framework; sourceTree = "<group>"; };
34893549
BCC5EAB422D5F98F00CF8900 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = ../Carthage/Build/watchOS/Bolts.framework; sourceTree = "<group>"; };
@@ -3569,7 +3629,6 @@
35693629
isa = PBXFrameworksBuildPhase;
35703630
buildActionMask = 2147483647;
35713631
files = (
3572-
B9312D5B23C4A6FC002D4A4C /* OCMock.framework in Frameworks */,
35733632
F5C42CC71B34C22100C720D8 /* AudioToolbox.framework in Frameworks */,
35743633
816F44761A8E8933009CDB32 /* StoreKit.framework in Frameworks */,
35753634
816F44771A8E8933009CDB32 /* libsqlite3.dylib in Frameworks */,
@@ -3585,7 +3644,6 @@
35853644
buildActionMask = 2147483647;
35863645
files = (
35873646
4A13525620282B4D000F5FD5 /* Parse.framework in Frameworks */,
3588-
B9312D5D23C4A775002D4A4C /* OCMock.framework in Frameworks */,
35893647
F5B0B3171B44A2CA00F3EBC4 /* StoreKit.framework in Frameworks */,
35903648
F5B0B3161B44A22300F3EBC4 /* SystemConfiguration.framework in Frameworks */,
35913649
);
@@ -3855,8 +3913,7 @@
38553913
09D3364C139C54940098E916 /* Frameworks */ = {
38563914
isa = PBXGroup;
38573915
children = (
3858-
B9312D5623C4A6FC002D4A4C /* OCMock.framework */,
3859-
B9312D5C23C4A775002D4A4C /* OCMock.framework */,
3916+
BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */,
38603917
BCC5EAAC22D5F96600CF8900 /* Bolts.framework */,
38613918
BCC5EAB222D5F97D00CF8900 /* Bolts.framework */,
38623919
BCC5EAB422D5F98F00CF8900 /* Bolts.framework */,
@@ -5099,6 +5156,20 @@
50995156
path = CurrentUserController;
51005157
sourceTree = "<group>";
51015158
};
5159+
BC105FBB24C5D0C900295EF7 /* Products */ = {
5160+
isa = PBXGroup;
5161+
children = (
5162+
BC105FC524C5D0C900295EF7 /* OCMock.framework */,
5163+
BC105FC724C5D0C900295EF7 /* OCMockTests.xctest */,
5164+
BC105FC924C5D0C900295EF7 /* libOCMock.a */,
5165+
BC105FCB24C5D0C900295EF7 /* OCMockLibTests.xctest */,
5166+
BC105FCD24C5D0C900295EF7 /* OCMock.framework */,
5167+
BC105FCF24C5D0C900295EF7 /* OCMock.framework */,
5168+
BC105FD124C5D0C900295EF7 /* OCMock.framework */,
5169+
);
5170+
name = Products;
5171+
sourceTree = "<group>";
5172+
};
51025173
F50C66301B33A6CE001941A6 /* Utilites */ = {
51035174
isa = PBXGroup;
51045175
children = (
@@ -6806,6 +6877,7 @@
68066877
buildRules = (
68076878
);
68086879
dependencies = (
6880+
BC105FD524C5D0E100295EF7 /* PBXTargetDependency */,
68096881
8111674C1B8402DF003CB026 /* PBXTargetDependency */,
68106882
4AE33A2D1F5451B20088DCA0 /* PBXTargetDependency */,
68116883
);
@@ -6826,6 +6898,7 @@
68266898
buildRules = (
68276899
);
68286900
dependencies = (
6901+
BC105FD324C5D0D600295EF7 /* PBXTargetDependency */,
68296902
811167471B8402DA003CB026 /* PBXTargetDependency */,
68306903
);
68316904
name = "ParseUnitTests-macOS";
@@ -6979,6 +7052,10 @@
69797052
ProductGroup = 4A13517620281768000F5FD5 /* Products */;
69807053
ProjectRef = 4A1351082027FCFB000F5FD5 /* Bolts.xcodeproj */;
69817054
},
7055+
{
7056+
ProductGroup = BC105FBB24C5D0C900295EF7 /* Products */;
7057+
ProjectRef = BC105FBA24C5D0C900295EF7 /* OCMock.xcodeproj */;
7058+
},
69827059
);
69837060
projectRoot = "";
69847061
targets = (
@@ -7074,6 +7151,55 @@
70747151
remoteRef = 4A13519720281768000F5FD5 /* PBXContainerItemProxy */;
70757152
sourceTree = BUILT_PRODUCTS_DIR;
70767153
};
7154+
BC105FC524C5D0C900295EF7 /* OCMock.framework */ = {
7155+
isa = PBXReferenceProxy;
7156+
fileType = wrapper.framework;
7157+
path = OCMock.framework;
7158+
remoteRef = BC105FC424C5D0C900295EF7 /* PBXContainerItemProxy */;
7159+
sourceTree = BUILT_PRODUCTS_DIR;
7160+
};
7161+
BC105FC724C5D0C900295EF7 /* OCMockTests.xctest */ = {
7162+
isa = PBXReferenceProxy;
7163+
fileType = wrapper.cfbundle;
7164+
path = OCMockTests.xctest;
7165+
remoteRef = BC105FC624C5D0C900295EF7 /* PBXContainerItemProxy */;
7166+
sourceTree = BUILT_PRODUCTS_DIR;
7167+
};
7168+
BC105FC924C5D0C900295EF7 /* libOCMock.a */ = {
7169+
isa = PBXReferenceProxy;
7170+
fileType = archive.ar;
7171+
path = libOCMock.a;
7172+
remoteRef = BC105FC824C5D0C900295EF7 /* PBXContainerItemProxy */;
7173+
sourceTree = BUILT_PRODUCTS_DIR;
7174+
};
7175+
BC105FCB24C5D0C900295EF7 /* OCMockLibTests.xctest */ = {
7176+
isa = PBXReferenceProxy;
7177+
fileType = wrapper.cfbundle;
7178+
path = OCMockLibTests.xctest;
7179+
remoteRef = BC105FCA24C5D0C900295EF7 /* PBXContainerItemProxy */;
7180+
sourceTree = BUILT_PRODUCTS_DIR;
7181+
};
7182+
BC105FCD24C5D0C900295EF7 /* OCMock.framework */ = {
7183+
isa = PBXReferenceProxy;
7184+
fileType = wrapper.framework;
7185+
path = OCMock.framework;
7186+
remoteRef = BC105FCC24C5D0C900295EF7 /* PBXContainerItemProxy */;
7187+
sourceTree = BUILT_PRODUCTS_DIR;
7188+
};
7189+
BC105FCF24C5D0C900295EF7 /* OCMock.framework */ = {
7190+
isa = PBXReferenceProxy;
7191+
fileType = wrapper.framework;
7192+
path = OCMock.framework;
7193+
remoteRef = BC105FCE24C5D0C900295EF7 /* PBXContainerItemProxy */;
7194+
sourceTree = BUILT_PRODUCTS_DIR;
7195+
};
7196+
BC105FD124C5D0C900295EF7 /* OCMock.framework */ = {
7197+
isa = PBXReferenceProxy;
7198+
fileType = wrapper.framework;
7199+
path = OCMock.framework;
7200+
remoteRef = BC105FD024C5D0C900295EF7 /* PBXContainerItemProxy */;
7201+
sourceTree = BUILT_PRODUCTS_DIR;
7202+
};
70777203
/* End PBXReferenceProxy section */
70787204

70797205
/* Begin PBXResourcesBuildPhase section */
@@ -8657,6 +8783,16 @@
86578783
target = 81C3821B19CCA89E0066284A /* Parse-iOS */;
86588784
targetProxy = 8111674B1B8402DF003CB026 /* PBXContainerItemProxy */;
86598785
};
8786+
BC105FD324C5D0D600295EF7 /* PBXTargetDependency */ = {
8787+
isa = PBXTargetDependency;
8788+
name = OCMock;
8789+
targetProxy = BC105FD224C5D0D600295EF7 /* PBXContainerItemProxy */;
8790+
};
8791+
BC105FD524C5D0E100295EF7 /* PBXTargetDependency */ = {
8792+
isa = PBXTargetDependency;
8793+
name = "OCMock iOS";
8794+
targetProxy = BC105FD424C5D0E100295EF7 /* PBXContainerItemProxy */;
8795+
};
86608796
/* End PBXTargetDependency section */
86618797

86628798
/* Begin PBXVariantGroup section */

Parse/Parse/Internal/ParseModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
*/
99

1010
#import <Foundation/Foundation.h>
11+
@import Bolts;
1112

1213
NS_ASSUME_NONNULL_BEGIN
1314

1415
@protocol ParseModule <NSObject>
1516

16-
- (void)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(nullable NSString *)clientKey;
17+
- (BFTask *)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(nullable NSString *)clientKey;
1718

1819
@end
1920

Parse/Parse/Internal/ParseModule.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,19 @@ - (NSUInteger)modulesCount {
7575
#pragma mark - ParseModule
7676
///--------------------------------------
7777

78-
- (void)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(nullable NSString *)clientKey {
78+
- (BFTask *)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(nullable NSString *)clientKey {
79+
80+
BFTaskCompletionSource *completion = [BFTaskCompletionSource new];
81+
7982
dispatch_async(dispatch_get_main_queue(), ^{
8083
[self enumerateModulesWithBlock:^(id<ParseModule> module, BOOL *stop, BOOL *remove) {
8184
[module parseDidInitializeWithApplicationId:applicationId clientKey:clientKey];
8285
}];
86+
[completion setResult:nil];
8387
});
88+
89+
return completion.task;
90+
8491
}
8592

8693
///--------------------------------------

Parse/Parse/Parse.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,13 @@ NS_ASSUME_NONNULL_BEGIN
243243

244244
@end
245245

246+
///--------------------------------------
247+
#pragma mark - Notifications
248+
///--------------------------------------
249+
250+
/**
251+
For testing purposes. Allows testers to know when init is complete.
252+
*/
253+
extern NSString *const _Nonnull PFParseInitializeDidCompleteNotification;
254+
246255
NS_ASSUME_NONNULL_END

Parse/Parse/Parse.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
#import "PFCategoryLoader.h"
3535

36+
NSString *const PFParseInitializeDidCompleteNotification = @"PFParseInitializeDidCompleteNotification";
37+
3638
@implementation Parse
3739

3840
static ParseManager *currentParseManager_;
@@ -84,9 +86,15 @@ + (void)initializeWithConfiguration:(ParseClientConfiguration *)configuration {
8486
[PFNetworkActivityIndicatorManager sharedManager].enabled = YES;
8587
#endif
8688

87-
[currentParseManager_ preloadDiskObjectsToMemoryAsync];
88-
89-
[[self parseModulesCollection] parseDidInitializeWithApplicationId:configuration.applicationId clientKey:configuration.clientKey];
89+
[[[currentParseManager_ preloadDiskObjectsToMemoryAsync] continueWithBlock:^id _Nullable(BFTask * _Nonnull t) {
90+
return [[self parseModulesCollection] parseDidInitializeWithApplicationId:configuration.applicationId
91+
clientKey:configuration.clientKey];
92+
}] continueWithSuccessBlock:^id _Nullable(BFTask * _Nonnull t) {
93+
[[NSNotificationCenter defaultCenter] postNotificationName:PFParseInitializeDidCompleteNotification
94+
object:nil];
95+
return nil;
96+
}];
97+
9098
}
9199

92100
+ (void)setServer:(nonnull NSString *)server {

Parse/Tests/Other/TestCases/TestCase/PFTestCase.m

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ - (void)setUp {
8888
}
8989

9090
- (void)tearDown {
91-
dispatch_sync(_mockQueue, ^{
92-
[self->_mocks makeObjectsPerformSelector:@selector(stopMocking)];
93-
});
94-
91+
[_mocks removeAllObjects];
9592
_mocks = nil;
9693
_mockQueue = nil;
9794

Parse/Tests/Other/TestCases/UnitTestCase/PFUnitTestCase.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ - (void)setUp {
3131
self.applicationId = [[NSUUID UUID] UUIDString];
3232
self.clientKey = [[NSUUID UUID] UUIDString];
3333

34+
XCTestExpectation *expect = [self expectationForNotification:PFParseInitializeDidCompleteNotification object:nil handler:^BOOL(NSNotification * _Nonnull notification) {
35+
return YES;
36+
}];
37+
3438
[Parse setApplicationId:self.applicationId clientKey:self.clientKey];
35-
36-
// NOTE: (richardross) This may seem crazy, but this is to solve an issue with OCMock's mocking, which isn't thread
37-
// Safe. +[Parse setApplicationId: clientKey:] launches a background task that uses several class methods that are
38-
// mocked throughout our unit tests, and this ensures that that task has completed before we continue.
39-
[[Parse _currentManager] clearEventuallyQueue];
39+
40+
[self waitForExpectations:@[expect] timeout:2];
4041
}
4142

4243
- (void)tearDown {

Parse/Tests/Unit/FileControllerTests.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ - (void)setUp {
7272
}
7373

7474
- (void)tearDown {
75-
[super tearDown];
76-
7775
[[PFFileManager removeItemAtPathAsync:[self temporaryDirectory]] waitUntilFinished];
76+
[super tearDown];
7877
}
7978

8079
///--------------------------------------

Parse/Tests/Unit/ParseModuleUnitTests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ @interface ParseTestModule : NSObject <ParseModule>
1818

1919
@implementation ParseTestModule
2020

21-
- (void)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey {
21+
- (BFTask *)parseDidInitializeWithApplicationId:(NSString *)applicationId clientKey:(NSString *)clientKey {
2222
self.didInitializeCalled = YES;
23+
return [BFTask taskWithResult:nil];
2324
}
2425

2526
@end

0 commit comments

Comments
 (0)