forked from Quick/Quick
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Quick#486 from briancroom/rework_suspendObservation
Adjust the way that test observation suspension works.
- Loading branch information
Showing
5 changed files
with
46 additions
and
13 deletions.
There are no files selected for viewing
Submodule Nimble
updated
76 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 7 additions & 11 deletions
18
Sources/QuickTests/Helpers/XCTestObservationCenter+QCKSuspendObservation.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
#import <XCTest/XCTest.h> | ||
|
||
/** | ||
Expose internal XCTest class and methods in order to run isolated XCTestSuite | ||
instances while the QuickTests test suite is running. | ||
If an Xcode upgrade causes QuickTests to crash when executing, or for tests to fail | ||
with the message "Timed out waiting for IDE barrier message to complete", it is | ||
likely that this internal interface has been changed. | ||
Add the ability to temporarily disable internal XCTest execution observation in | ||
order to run isolated XCTestSuite instances while the QuickTests test suite is running. | ||
*/ | ||
@interface XCTestObservationCenter (QCKSuspendObservation) | ||
|
||
/** | ||
Suspends test suite observation for the duration that the block is executing. | ||
Any test suites that are executed within the block do not generate any log output. | ||
Failures are still reported. | ||
Suspends test suite observation for XCTest-provided observers for the duration that | ||
the block is executing. Any test suites that are executed within the block do not | ||
generate any log output. Failures are still reported. | ||
Use this method to run XCTestSuite objects while another XCTestSuite is running. | ||
Without this method, tests fail with the message: "Timed out waiting for IDE | ||
barrier message to complete". | ||
barrier message to complete" or "Unexpected TestSuiteDidStart". | ||
*/ | ||
- (void)_suspendObservationForBlock:(void (^)(void))block; | ||
- (void)qck_suspendObservationForBlock:(void (^)(void))block; | ||
|
||
@end |
23 changes: 23 additions & 0 deletions
23
Sources/QuickTests/Helpers/XCTestObservationCenter+QCKSuspendObservation.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@import XCTest; | ||
#import <objc/runtime.h> | ||
|
||
@interface XCTestObservationCenter (Redeclaration) | ||
- (NSMutableSet *)observers; | ||
@end | ||
|
||
@implementation XCTestObservationCenter (QCKSuspendObservation) | ||
|
||
static BOOL (^isFromApple)(id, BOOL *) = ^BOOL(id observer, BOOL *stop){ | ||
return [[NSBundle bundleForClass:[observer class]].bundleIdentifier containsString:@"com.apple.dt.XCTest"]; | ||
}; | ||
|
||
- (void)qck_suspendObservationForBlock:(void (^)(void))block { | ||
NSSet *observersToSuspend = [[self observers] objectsPassingTest:isFromApple]; | ||
[[self observers] minusSet:observersToSuspend]; | ||
|
||
block(); | ||
|
||
[[self observers] unionSet:observersToSuspend]; | ||
} | ||
|
||
@end |