Skip to content

Commit

Permalink
Merge pull request Quick#486 from briancroom/rework_suspendObservation
Browse files Browse the repository at this point in the history
Adjust the way that test observation suspension works.
  • Loading branch information
modocache committed Mar 2, 2016
2 parents 60b04ae + 6105748 commit 8be4a82
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Externals/Nimble
Submodule Nimble updated 76 files
+1 −0 .swift-version
+17 −9 .travis.yml
+32 −4 Nimble.xcodeproj/project.pbxproj
+52 −0 Nimble/Utils/PostNotification.swift
+78 −0 NimbleTests/Matchers/PostNotificationTest.swift
+1 −1 README.md
+4 −1 Sources/Nimble/Adapters/NimbleEnvironment.swift
+39 −2 Sources/Nimble/Adapters/NimbleXCTestHandler.swift
+7 −5 Sources/Nimble/DSL+Wait.swift
+14 −6 Sources/Nimble/DSL.swift
+2 −2 Sources/Nimble/FailureMessage.swift
+2 −0 Sources/Nimble/Matchers/AllPass.swift
+6 −2 Sources/Nimble/Matchers/BeAKindOf.swift
+8 −2 Sources/Nimble/Matchers/BeAnInstanceOf.swift
+7 −0 Sources/Nimble/Matchers/BeCloseTo.swift
+4 −2 Sources/Nimble/Matchers/BeEmpty.swift
+2 −0 Sources/Nimble/Matchers/BeGreaterThan.swift
+2 −0 Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift
+15 −4 Sources/Nimble/Matchers/BeIdenticalTo.swift
+2 −0 Sources/Nimble/Matchers/BeLessThan.swift
+2 −0 Sources/Nimble/Matchers/BeLessThanOrEqual.swift
+2 −0 Sources/Nimble/Matchers/BeLogical.swift
+2 −0 Sources/Nimble/Matchers/BeNil.swift
+2 −0 Sources/Nimble/Matchers/BeginWith.swift
+9 −8 Sources/Nimble/Matchers/Contain.swift
+2 −0 Sources/Nimble/Matchers/EndWith.swift
+2 −0 Sources/Nimble/Matchers/Equal.swift
+3 −1 Sources/Nimble/Matchers/HaveCount.swift
+3 −0 Sources/Nimble/Matchers/Match.swift
+61 −3 Sources/Nimble/Matchers/MatcherProtocols.swift
+66 −0 Sources/Nimble/Matchers/PostNotification.swift
+4 −1 Sources/Nimble/Matchers/RaisesException.swift
+10 −11 Sources/Nimble/Matchers/SatisfyAnyOf.swift
+7 −3 Sources/Nimble/ObjCExpectation.swift
+10 −6 Sources/Nimble/Utils/Async.swift
+31 −0 Sources/Nimble/Utils/ExceptionCapture.swift
+7 −6 Sources/Nimble/Utils/Functional.swift
+13 −3 Sources/Nimble/Utils/SourceLocation.swift
+20 −9 Sources/Nimble/Utils/Stringers.swift
+4 −0 Sources/Nimble/Wrappers/AsyncMatcherWrapper.swift
+3 −0 Sources/Nimble/Wrappers/ObjCMatcher.swift
+18 −0 Sources/Nimble/objc/CurrentTestCaseTracker.m
+4 −0 Sources/Nimble/objc/DSL.h
+4 −0 Sources/Nimble/objc/DSL.m
+21 −1 Sources/NimbleTests/AsynchronousTest.swift
+35 −0 Sources/NimbleTests/Helpers/XCTestCaseProvider.swift
+23 −18 Sources/NimbleTests/Helpers/utils.swift
+12 −1 Sources/NimbleTests/Matchers/AllPassTest.swift
+12 −1 Sources/NimbleTests/Matchers/BeAKindOfTest.swift
+17 −3 Sources/NimbleTests/Matchers/BeAnInstanceOfTest.swift
+25 −4 Sources/NimbleTests/Matchers/BeCloseToTest.swift
+15 −3 Sources/NimbleTests/Matchers/BeEmptyTest.swift
+10 −1 Sources/NimbleTests/Matchers/BeGreaterThanOrEqualToTest.swift
+19 −2 Sources/NimbleTests/Matchers/BeGreaterThanTest.swift
+21 −9 Sources/NimbleTests/Matchers/BeIdenticalToObjectTest.swift
+43 −11 Sources/NimbleTests/Matchers/BeIdenticalToTest.swift
+11 −1 Sources/NimbleTests/Matchers/BeLessThanOrEqualToTest.swift
+18 −2 Sources/NimbleTests/Matchers/BeLessThanTest.swift
+42 −4 Sources/NimbleTests/Matchers/BeLogicalTest.swift
+7 −1 Sources/NimbleTests/Matchers/BeNilTest.swift
+12 −3 Sources/NimbleTests/Matchers/BeginWithTest.swift
+15 −3 Sources/NimbleTests/Matchers/ContainTest.swift
+10 −1 Sources/NimbleTests/Matchers/EndWithTest.swift
+23 −1 Sources/NimbleTests/Matchers/EqualTest.swift
+9 −1 Sources/NimbleTests/Matchers/HaveCountTest.swift
+15 −2 Sources/NimbleTests/Matchers/MatchTest.swift
+89 −0 Sources/NimbleTests/Matchers/PostNotificationTest.swift
+14 −1 Sources/NimbleTests/Matchers/RaisesExceptionTest.swift
+12 −1 Sources/NimbleTests/Matchers/SatisfyAnyOfTest.swift
+13 −1 Sources/NimbleTests/Matchers/ThrowErrorTest.swift
+27 −6 Sources/NimbleTests/SynchronousTests.swift
+17 −1 Sources/NimbleTests/UserDescriptionTest.swift
+36 −0 Sources/NimbleTests/main.swift
+26 −0 Sources/NimbleTests/objc/ObjCBeIdenticalToTest.m
+5 −0 script/travis-install-linux
+10 −1 test
14 changes: 14 additions & 0 deletions Quick.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
96327C661C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m in Sources */ = {isa = PBXBuildFile; fileRef = 96327C621C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m */; };
96327C671C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m in Sources */ = {isa = PBXBuildFile; fileRef = 96327C621C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m */; };
96327C681C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m in Sources */ = {isa = PBXBuildFile; fileRef = 96327C621C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m */; };
AE4E58131C73097A00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
AE4E58141C73097A00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
AE4E58151C73097C00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
AE4E58161C73097C00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
AE4E58171C73097E00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
AE4E58181C73097E00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */; };
CE57CEDD1C430BD200D63004 /* NSBundle+CurrentTestBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */; };
CE57CEDE1C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */; };
CE57CEDF1C430BD200D63004 /* QuickTestSuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */; };
Expand Down Expand Up @@ -443,6 +449,7 @@
8D010A561C11726F00633E2B /* DescribeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DescribeTests.swift; sourceTree = "<group>"; };
96327C611C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "QuickSpec+QuickSpec_MethodList.h"; sourceTree = "<group>"; };
96327C621C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "QuickSpec+QuickSpec_MethodList.m"; sourceTree = "<group>"; };
AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCTestObservationCenter+QCKSuspendObservation.m"; sourceTree = "<group>"; };
CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSBundle+CurrentTestBundle.swift"; sourceTree = "<group>"; };
CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuickSelectedTestSuiteBuilder.swift; sourceTree = "<group>"; };
CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuickTestSuite.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -626,6 +633,7 @@
DA8F919819F31680006F6675 /* XCTestObservationCenter+QCKSuspendObservation.h */,
96327C611C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.h */,
96327C621C56E90C00405AB3 /* QuickSpec+QuickSpec_MethodList.m */,
AEB080BB1C72F028004917D3 /* XCTestObservationCenter+QCKSuspendObservation.m */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -1228,6 +1236,7 @@
1F118D131BDCA556005013A2 /* ItTests+ObjC.m in Sources */,
1F118D191BDCA556005013A2 /* AfterEachTests+ObjC.m in Sources */,
1F118D221BDCA556005013A2 /* SharedExamples+BeforeEachTests.swift in Sources */,
AE4E58171C73097E00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
1F118D211BDCA556005013A2 /* SharedExamplesTests+ObjC.m in Sources */,
1F118D201BDCA556005013A2 /* SharedExamplesTests.swift in Sources */,
1F118D0C1BDCA543005013A2 /* QuickConfigurationTests.m in Sources */,
Expand All @@ -1251,6 +1260,7 @@
34C586061C4ABD4100D4F057 /* XCTestCaseProvider.swift in Sources */,
1F118D241BDCA561005013A2 /* FocusedTests.swift in Sources */,
1F118D251BDCA561005013A2 /* FocusedTests+ObjC.m in Sources */,
AE4E58181C73097E00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1305,6 +1315,7 @@
4748E8951A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m in Sources */,
DA8F91AF19F32CE2006F6675 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift in Sources */,
DAE714FB19FF682A005905B8 /* Configuration+AfterEachTests.swift in Sources */,
AE4E58151C73097C00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
471590411A488F3F00FBA644 /* PendingTests+ObjC.m in Sources */,
DA8F919E19F31921006F6675 /* FailureTests+ObjC.m in Sources */,
DAE714F419FF65E7005905B8 /* Configuration+BeforeEach.swift in Sources */,
Expand All @@ -1328,6 +1339,7 @@
34C586021C4ABD3F00D4F057 /* XCTestCaseProvider.swift in Sources */,
DA5663F41A4C8D9A00193C88 /* FocusedTests.swift in Sources */,
DAF28BC31A4DB8EC00A5D9BF /* FocusedTests+ObjC.m in Sources */,
AE4E58141C73097A00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -1339,6 +1351,7 @@
34C586041C4ABD4000D4F057 /* XCTestCaseProvider.swift in Sources */,
DA9876C11A4C87200004AA17 /* FocusedTests.swift in Sources */,
DAF28BC41A4DB8EC00A5D9BF /* FocusedTests+ObjC.m in Sources */,
AE4E58161C73097C00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1393,6 +1406,7 @@
4748E8941A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m in Sources */,
DA8F91AE19F32CE2006F6675 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift in Sources */,
DAE714FA19FF682A005905B8 /* Configuration+AfterEachTests.swift in Sources */,
AE4E58131C73097A00420A2E /* XCTestObservationCenter+QCKSuspendObservation.m in Sources */,
471590401A488F3F00FBA644 /* PendingTests+ObjC.m in Sources */,
DA8F919D19F31921006F6675 /* FailureTests+ObjC.m in Sources */,
DAE714F319FF65E7005905B8 /* Configuration+BeforeEach.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/QuickTests/Helpers/QCKSpecRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[World sharedWorld].isRunningAdditionalSuites = YES;

__block XCTestRun *result = nil;
[[XCTestObservationCenter sharedTestObservationCenter] _suspendObservationForBlock:^{
[[XCTestObservationCenter sharedTestObservationCenter] qck_suspendObservationForBlock:^{
if ([suite respondsToSelector:@selector(runTest)]) {
[suite runTest];
result = suite.testRun;
Expand Down
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
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

0 comments on commit 8be4a82

Please sign in to comment.