-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathSLRemotingTestsUtils.h
45 lines (40 loc) · 1.48 KB
/
SLRemotingTestsUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file SLRemotingTestsUtils.h
*
* @author Michael Schoonmaker
* @copyright (c) 2013 StrongLoop. All rights reserved.
*/
#import <Foundation/Foundation.h>
/**
* Marks the start of an asynchronous unit test.
*/
// NOTE: since the CI uses Xcode 5, we cannot depend on XCTestExpectation.
// Use dispatch_semaphore instead.
//
// #define ASYNC_TEST_START XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithUTF8String:__FUNCTION__]];
#define ASYNC_TEST_START dispatch_semaphore_t sen_semaphore = dispatch_semaphore_create(0);
/**
* Marks the end of an asynchronous unit test.
*/
// #define ASYNC_TEST_END [self waitForExpectationsWithTimeout:10 handler:nil];
#define ASYNC_TEST_END \
while (dispatch_semaphore_wait(sen_semaphore, DISPATCH_TIME_NOW)) \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
/**
* Signals the completion of an asynchronous unit test.
*/
// #define ASYNC_TEST_SIGNAL [expectation fulfill];
#define ASYNC_TEST_SIGNAL dispatch_semaphore_signal(sen_semaphore);
/**
* Fails an asynchronous unit test, additionally signaling its completion.
*/
// #define ASYNC_TEST_FAILURE_BLOCK \
// ^(NSError *error) { \
// XCTFail(@"Test failed: %@", error.description); \
// [expectation fulfill]; \
// }
#define ASYNC_TEST_FAILURE_BLOCK \
^(NSError *error) { \
XCTFail(@"Test failed: %@", error.description); \
ASYNC_TEST_SIGNAL \
}