Skip to content

Commit 5d58748

Browse files
authored
Update checkout action (#287)
* Update checkout action * Make testObjectRemove less flakey * Make testObjectRemoveAll less flakey
1 parent 4c3389b commit 5d58748

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
matrix:
1919
platform: ['iOS Simulator,name=iPhone 8']
2020
steps:
21-
- uses: actions/checkout@v1
21+
- uses: actions/checkout@v2
2222
- name: Test
2323
run: make test
2424
analyze:
2525
name: Analyze
2626
runs-on: macOS-latest
2727
steps:
28-
- uses: actions/checkout@v1
28+
- uses: actions/checkout@v2
2929
- name: analyze
3030
run: make analyze
3131
cocoapods:

Tests/PINCacheTests.m

+9-13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ @interface PINDiskCache()
2323

2424
@property (assign, nonatomic) BOOL diskStateKnown;
2525
@property (strong, nonatomic) NSDictionary *metadata;
26+
@property (readonly) PINOperationQueue *operationQueue;
2627

2728
+ (dispatch_queue_t)sharedTrashQueue;
2829
+ (NSURL *)sharedTrashURL;
@@ -272,7 +273,6 @@ - (void)testObjectGetWithInvalidKey
272273
- (void)testObjectRemove
273274
{
274275
NSString *key = @"key";
275-
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
276276

277277
self.cache[key] = [self image];
278278

@@ -285,13 +285,12 @@ - (void)testObjectRemove
285285
self.cache.diskCache.didRemoveObjectBlock = ^(PINDiskCache * _Nonnull cache, NSString * _Nonnull key, id<NSCoding> _Nullable object) {
286286
didRemoveObjectBlockCalled = YES;
287287
};
288-
289-
[self.cache removeObjectForKeyAsync:key completion:^(id<PINCaching> cache, NSString *key, id object) {
290-
dispatch_semaphore_signal(semaphore);
291-
}];
292-
293-
dispatch_semaphore_wait(semaphore, [self timeout]);
294288

289+
// Clear out operation queue to ensure blocks are set.
290+
[self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished];
291+
292+
[self.cache removeObjectForKey:key];
293+
295294
id object = self.cache[key];
296295

297296
XCTAssertNil(object, @"object was not removed");
@@ -303,7 +302,6 @@ - (void)testObjectRemoveAll
303302
{
304303
NSString *key1 = @"key1";
305304
NSString *key2 = @"key2";
306-
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
307305

308306
self.cache[key1] = key1;
309307
self.cache[key2] = key2;
@@ -317,12 +315,10 @@ - (void)testObjectRemoveAll
317315
self.cache.diskCache.didRemoveAllObjectsBlock = ^(id<PINCaching> _Nonnull cache) {
318316
didRemoveAllObjectsBlockCalled = YES;
319317
};
320-
321-
[self.cache removeAllObjectsAsync:^(id<PINCaching> cache) {
322-
dispatch_semaphore_signal(semaphore);
323-
}];
324318

325-
dispatch_semaphore_wait(semaphore, [self timeout]);
319+
[self.cache.diskCache.operationQueue waitUntilAllOperationsAreFinished];
320+
321+
[self.cache removeAllObjects];
326322

327323
id object1 = self.cache[key1];
328324
id object2 = self.cache[key2];

0 commit comments

Comments
 (0)