Skip to content

Commit

Permalink
Fix ConcurrentTest to support XCode 10
Browse files Browse the repository at this point in the history
  • Loading branch information
pasin committed Sep 12, 2018
1 parent 174bbde commit d177e26
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Objective-C/Tests/ConcurrentTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,19 @@ - (void) concurrentRuns: (NSUInteger)nRuns
NSMutableArray* expects = [NSMutableArray arrayWithCapacity: nRuns];
for (NSUInteger i = 0; i < nRuns; i++) {
NSString* name = [NSString stringWithFormat: @"Queue-%ld", (long)i];
XCTestExpectation* exp = [self expectationWithDescription: name];
[expects addObject: exp];
XCTestExpectation* exp = nil;
if (wait) {
exp = [self expectationWithDescription: name];
[expects addObject: exp];
}
dispatch_queue_t queue = dispatch_queue_create([name UTF8String], NULL);
dispatch_async(queue, ^{
block(i);
[exp fulfill];
});
}

if (wait && expects.count > 0) {
if (expects.count > 0) {
[self waitForExpectations: expects timeout: 60.0];
}
}
Expand Down Expand Up @@ -313,7 +316,7 @@ - (void) testDatabaseChange {
[exp1 fulfill];
}];

[self waitForExpectationsWithTimeout: 10.0 handler:^(NSError * _Nullable error) { }];
[self waitForExpectations: @[exp2] timeout: 10.0]; // Test deadlock
}


Expand All @@ -330,7 +333,7 @@ - (void) testDocumentChange {
[exp1 fulfill];
}];

[self waitForExpectationsWithTimeout: 10.0 handler:^(NSError * _Nullable error) { }];
[self waitForExpectations: @[exp2] timeout: 10.0]; // Test deadlock
}

@end

0 comments on commit d177e26

Please sign in to comment.