From cafe47e9bea9649a0e9b4a2b96ca44434bbac411 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 22 Feb 2023 10:09:29 +0100 Subject: [PATCH] chore: Make sure the test is never going to be unexpectedly interrupted (#664) --- WebDriverAgent.xcodeproj/project.pbxproj | 24 ++++++------ .../Categories/XCTIssue+FBPatcher.h | 18 +++++++++ .../Categories/XCTIssue+FBPatcher.m | 33 ++++++++++++++++ .../Utilities/FBFailureProofTestCase.m | 38 ++++++++++--------- ...estCaseImplementationFailureHoldingProxy.h | 29 -------------- ...estCaseImplementationFailureHoldingProxy.m | 38 ------------------- WebDriverAgentLib/WebDriverAgentLib.h | 1 + 7 files changed, 85 insertions(+), 96 deletions(-) create mode 100644 WebDriverAgentLib/Categories/XCTIssue+FBPatcher.h create mode 100644 WebDriverAgentLib/Categories/XCTIssue+FBPatcher.m delete mode 100644 WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.h delete mode 100644 WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.m diff --git a/WebDriverAgent.xcodeproj/project.pbxproj b/WebDriverAgent.xcodeproj/project.pbxproj index 0378351c1..7b8cf620e 100644 --- a/WebDriverAgent.xcodeproj/project.pbxproj +++ b/WebDriverAgent.xcodeproj/project.pbxproj @@ -74,7 +74,6 @@ 641EE5F52240C5CA00173FCB /* XCUIElement+FBUID.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B49EC61ED1A58100D51AD6 /* XCUIElement+FBUID.m */; }; 641EE5F62240C5CA00173FCB /* FBRouteRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9AB7881CAEDF0C008C271F /* FBRouteRequest.m */; }; 641EE5F72240C5CA00173FCB /* FBResponseJSONPayload.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9AB7811CAEDF0C008C271F /* FBResponseJSONPayload.m */; }; - 641EE5F82240C5CA00173FCB /* FBXCTestCaseImplementationFailureHoldingProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */; }; 641EE5F92240C5CA00173FCB /* FBMjpegServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7155D702211DCEF400166C20 /* FBMjpegServer.m */; }; 641EE5FA2240C5CA00173FCB /* XCUIDevice+FBHealthCheck.m in Sources */ = {isa = PBXBuildFile; fileRef = EEDFE1201D9C06F800E6FFE5 /* XCUIDevice+FBHealthCheck.m */; }; 641EE5FD2240C5CA00173FCB /* FBBaseActionsSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7140974D1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m */; }; @@ -275,7 +274,6 @@ 641EE6D72240C5CA00173FCB /* XCTestObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACE21E3B77D600A02D78 /* XCTestObserver.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6D82240C5CA00173FCB /* XCUIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACFE1E3B77D600A02D78 /* XCUIElement.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6D92240C5CA00173FCB /* XCKeyboardInputSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACBE1E3B77D600A02D78 /* XCKeyboardInputSolver.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 641EE6DA2240C5CA00173FCB /* FBXCTestCaseImplementationFailureHoldingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */; }; 641EE6DB2240C5CA00173FCB /* FBPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 71930C4020662E1F00D3AFEC /* FBPasteboard.h */; }; 641EE6DC2240C5CA00173FCB /* FBAppiumActionsSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 714097451FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h */; }; 641EE6DD2240C5CA00173FCB /* FBDebugLogDelegateDecorator.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E27181D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -449,6 +447,10 @@ 71A224E51DE2F56600844D55 /* NSPredicate+FBFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A224E31DE2F56600844D55 /* NSPredicate+FBFormat.h */; }; 71A224E61DE2F56600844D55 /* NSPredicate+FBFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A224E41DE2F56600844D55 /* NSPredicate+FBFormat.m */; }; 71A224E81DE326C500844D55 /* NSPredicateFBFormatTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A224E71DE326C500844D55 /* NSPredicateFBFormatTests.m */; }; + 71A5C67329A4F39600421C37 /* XCTIssue+FBPatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A5C67129A4F39600421C37 /* XCTIssue+FBPatcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 71A5C67429A4F39600421C37 /* XCTIssue+FBPatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A5C67129A4F39600421C37 /* XCTIssue+FBPatcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 71A5C67529A4F39600421C37 /* XCTIssue+FBPatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A5C67229A4F39600421C37 /* XCTIssue+FBPatcher.m */; }; + 71A5C67629A4F39600421C37 /* XCTIssue+FBPatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A5C67229A4F39600421C37 /* XCTIssue+FBPatcher.m */; }; 71A7EAF51E20516B001DA4F2 /* XCUIElement+FBClassChain.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A7EAF31E20516B001DA4F2 /* XCUIElement+FBClassChain.h */; }; 71A7EAF61E20516B001DA4F2 /* XCUIElement+FBClassChain.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A7EAF41E20516B001DA4F2 /* XCUIElement+FBClassChain.m */; }; 71A7EAF91E224648001DA4F2 /* FBClassChainQueryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 71A7EAF71E224648001DA4F2 /* FBClassChainQueryParser.h */; }; @@ -765,8 +767,6 @@ EE6B64FE1D0F86EF00E85F5D /* XCTestPrivateSymbols.m in Sources */ = {isa = PBXBuildFile; fileRef = EE6B64FC1D0F86EF00E85F5D /* XCTestPrivateSymbols.m */; }; EE7E271C1D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E27181D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h */; settings = {ATTRIBUTES = (Public, ); }; }; EE7E271D1D06C69F001BEC7B /* FBDebugLogDelegateDecorator.m in Sources */ = {isa = PBXBuildFile; fileRef = EE7E27191D06C69F001BEC7B /* FBDebugLogDelegateDecorator.m */; }; - EE7E271E1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */; }; - EE7E271F1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */; }; EE8BA97A1DCCED9A00A9DEF8 /* FBNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8BA9791DCCED9A00A9DEF8 /* FBNavigationController.m */; }; EE8DDD7E20C5733C004D4925 /* XCUIElement+FBForceTouch.m in Sources */ = {isa = PBXBuildFile; fileRef = EE8DDD7C20C5733B004D4925 /* XCUIElement+FBForceTouch.m */; }; EE8DDD7F20C5733C004D4925 /* XCUIElement+FBForceTouch.h in Headers */ = {isa = PBXBuildFile; fileRef = EE8DDD7D20C5733C004D4925 /* XCUIElement+FBForceTouch.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1036,6 +1036,8 @@ 71A224E31DE2F56600844D55 /* NSPredicate+FBFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSPredicate+FBFormat.h"; path = "../Utilities/NSPredicate+FBFormat.h"; sourceTree = ""; }; 71A224E41DE2F56600844D55 /* NSPredicate+FBFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSPredicate+FBFormat.m"; path = "../Utilities/NSPredicate+FBFormat.m"; sourceTree = ""; }; 71A224E71DE326C500844D55 /* NSPredicateFBFormatTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSPredicateFBFormatTests.m; sourceTree = ""; }; + 71A5C67129A4F39600421C37 /* XCTIssue+FBPatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCTIssue+FBPatcher.h"; sourceTree = ""; }; + 71A5C67229A4F39600421C37 /* XCTIssue+FBPatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCTIssue+FBPatcher.m"; sourceTree = ""; }; 71A7EAF31E20516B001DA4F2 /* XCUIElement+FBClassChain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCUIElement+FBClassChain.h"; sourceTree = ""; }; 71A7EAF41E20516B001DA4F2 /* XCUIElement+FBClassChain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCUIElement+FBClassChain.m"; sourceTree = ""; }; 71A7EAF71E224648001DA4F2 /* FBClassChainQueryParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBClassChainQueryParser.h; sourceTree = ""; }; @@ -1265,8 +1267,6 @@ EE6B64FC1D0F86EF00E85F5D /* XCTestPrivateSymbols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCTestPrivateSymbols.m; sourceTree = ""; }; EE7E27181D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBDebugLogDelegateDecorator.h; sourceTree = ""; }; EE7E27191D06C69F001BEC7B /* FBDebugLogDelegateDecorator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBDebugLogDelegateDecorator.m; sourceTree = ""; }; - EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBXCTestCaseImplementationFailureHoldingProxy.h; sourceTree = ""; }; - EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBXCTestCaseImplementationFailureHoldingProxy.m; sourceTree = ""; }; EE836C021C0F118600D87246 /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; EE8BA9781DCCED9A00A9DEF8 /* FBNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBNavigationController.h; sourceTree = ""; }; EE8BA9791DCCED9A00A9DEF8 /* FBNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBNavigationController.m; sourceTree = ""; }; @@ -1727,6 +1727,8 @@ 716E0BCD1E917E810087A825 /* NSString+FBXMLSafeString.m */, 714E14B629805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.h */, 714E14B729805CAE00375DD7 /* XCAXClient_iOS+FBSnapshotReqParams.m */, + 71A5C67129A4F39600421C37 /* XCTIssue+FBPatcher.h */, + 71A5C67229A4F39600421C37 /* XCTIssue+FBPatcher.m */, AD6C269A1CF2494200F8B5FF /* XCUIApplication+FBHelpers.h */, AD6C269B1CF2494200F8B5FF /* XCUIApplication+FBHelpers.m */, 71C8E54F25399A6B008572C1 /* XCUIApplication+FBQuiescence.h */, @@ -1940,8 +1942,6 @@ 7157B290221DADD2001C348C /* FBXCAXClientProxy.m */, EE5A24401F136C8D0078B1D9 /* FBXCodeCompatibility.h */, EE5A24411F136C8D0078B1D9 /* FBXCodeCompatibility.m */, - EE7E271A1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h */, - EE7E271B1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m */, EE35AD791E3B80C000A02D78 /* FBXCTestDaemonsProxy.h */, EE35AD7A1E3B80C000A02D78 /* FBXCTestDaemonsProxy.m */, 714D88CA2733FB970074A925 /* FBXMLGenerationOptions.h */, @@ -2349,6 +2349,7 @@ 641EE67B2240C5CA00173FCB /* XCUIRecorderUtilities.h in Headers */, 6496A5DA230D6EB30087F8CB /* AXSettings.h in Headers */, 641EE67C2240C5CA00173FCB /* XCTestCaseRun.h in Headers */, + 71A5C67429A4F39600421C37 /* XCTIssue+FBPatcher.h in Headers */, 641EE67D2240C5CA00173FCB /* XCTestConfiguration.h in Headers */, 641EE67E2240C5CA00173FCB /* _XCTDarwinNotificationExpectationImplementation.h in Headers */, 641EE67F2240C5CA00173FCB /* XCTestExpectation.h in Headers */, @@ -2456,7 +2457,6 @@ 641EE6D72240C5CA00173FCB /* XCTestObserver.h in Headers */, 641EE6D82240C5CA00173FCB /* XCUIElement.h in Headers */, 641EE6D92240C5CA00173FCB /* XCKeyboardInputSolver.h in Headers */, - 641EE6DA2240C5CA00173FCB /* FBXCTestCaseImplementationFailureHoldingProxy.h in Headers */, 718226CB2587443700661B83 /* GCDAsyncUdpSocket.h in Headers */, 641EE6DB2240C5CA00173FCB /* FBPasteboard.h in Headers */, 711CD03525ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h in Headers */, @@ -2619,6 +2619,7 @@ E444DC83249131B10060D7EB /* DDNumber.h in Headers */, EE35AD271E3B77D600A02D78 /* XCApplicationMonitor.h in Headers */, EE8DDD7F20C5733C004D4925 /* XCUIElement+FBForceTouch.h in Headers */, + 71A5C67329A4F39600421C37 /* XCTIssue+FBPatcher.h in Headers */, EE158AEA1CBD456F00A3E3F0 /* FBRuntimeUtils.h in Headers */, 7136A4791E8918E60024FC3D /* XCUIElement+FBPickerWheel.h in Headers */, E444DCB324913C220060D7EB /* RoutingHTTPServer.h in Headers */, @@ -2696,7 +2697,6 @@ EE35AD531E3B77D600A02D78 /* XCTestObserver.h in Headers */, EE35AD6F1E3B77D600A02D78 /* XCUIElement.h in Headers */, EE35AD2F1E3B77D600A02D78 /* XCKeyboardInputSolver.h in Headers */, - EE7E271E1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.h in Headers */, 71930C4220662E1F00D3AFEC /* FBPasteboard.h in Headers */, 714097471FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h in Headers */, EE7E271C1D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h in Headers */, @@ -3124,7 +3124,6 @@ 641EE5F62240C5CA00173FCB /* FBRouteRequest.m in Sources */, 641EE5F72240C5CA00173FCB /* FBResponseJSONPayload.m in Sources */, 718226D12587443700661B83 /* GCDAsyncUdpSocket.m in Sources */, - 641EE5F82240C5CA00173FCB /* FBXCTestCaseImplementationFailureHoldingProxy.m in Sources */, 641EE5F92240C5CA00173FCB /* FBMjpegServer.m in Sources */, 641EE5FA2240C5CA00173FCB /* XCUIDevice+FBHealthCheck.m in Sources */, 641EE5FD2240C5CA00173FCB /* FBBaseActionsSynthesizer.m in Sources */, @@ -3154,6 +3153,7 @@ 641EE6102240C5CA00173FCB /* FBImageUtils.m in Sources */, 641EE6112240C5CA00173FCB /* FBSession.m in Sources */, 641EE6122240C5CA00173FCB /* FBFindElementCommands.m in Sources */, + 71A5C67629A4F39600421C37 /* XCTIssue+FBPatcher.m in Sources */, 641EE6132240C5CA00173FCB /* FBDebugLogDelegateDecorator.m in Sources */, 641EE6142240C5CA00173FCB /* FBAlertViewCommands.m in Sources */, 71414EDB2670A1EE003A8C5D /* LRUCacheNode.m in Sources */, @@ -3201,6 +3201,7 @@ 7136A47A1E8918E60024FC3D /* XCUIElement+FBPickerWheel.m in Sources */, E444DC84249131B10060D7EB /* DDRange.m in Sources */, 6385F4A7220A40760095BBDB /* XCUIApplicationProcessDelay.m in Sources */, + 71A5C67529A4F39600421C37 /* XCTIssue+FBPatcher.m in Sources */, 711084451DA3AA7500F913D6 /* FBXPath.m in Sources */, 719CD8FD2126C88B00C7D0C2 /* XCUIApplication+FBAlert.m in Sources */, 13DE7A45287C2A8D003243C6 /* FBXCAccessibilityElement.m in Sources */, @@ -3241,7 +3242,6 @@ EE158AE21CBD456F00A3E3F0 /* FBRouteRequest.m in Sources */, EE158ADB1CBD456F00A3E3F0 /* FBResponseJSONPayload.m in Sources */, 714EAA0F2673FDFE005C5B47 /* FBCapabilities.m in Sources */, - EE7E271F1D06C69F001BEC7B /* FBXCTestCaseImplementationFailureHoldingProxy.m in Sources */, 7155D704211DCEF400166C20 /* FBMjpegServer.m in Sources */, EEDFE1221D9C06F800E6FFE5 /* XCUIDevice+FBHealthCheck.m in Sources */, 714D88CE2733FB970074A925 /* FBXMLGenerationOptions.m in Sources */, diff --git a/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.h b/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.h new file mode 100644 index 000000000..b4cdf1d44 --- /dev/null +++ b/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.h @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XCTIssue (AMPatcher) + +@end + +NS_ASSUME_NONNULL_END diff --git a/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.m b/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.m new file mode 100644 index 000000000..dc27e86a6 --- /dev/null +++ b/WebDriverAgentLib/Categories/XCTIssue+FBPatcher.m @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#import "XCTIssue+FBPatcher.h" + +#import + +static _Bool swizzledShouldInterruptTest(id self, SEL _cmd) +{ + return NO; +} + +@implementation XCTIssue (AMPatcher) + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-load-method" ++ (void)load +{ + SEL originalShouldInterruptTest = NSSelectorFromString(@"shouldInterruptTest"); + if (nil == originalShouldInterruptTest) return; + Method originalShouldInterruptTestMethod = class_getInstanceMethod(self.class, originalShouldInterruptTest); + if (nil == originalShouldInterruptTestMethod) return; + method_setImplementation(originalShouldInterruptTestMethod, (IMP)swizzledShouldInterruptTest); +} +#pragma clang diagnostic pop + +@end diff --git a/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m b/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m index 3a3987e87..72d79ee1c 100644 --- a/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m +++ b/WebDriverAgentLib/Utilities/FBFailureProofTestCase.m @@ -9,13 +9,7 @@ #import "FBFailureProofTestCase.h" -#import "FBExceptions.h" #import "FBLogger.h" -#import "FBXCTestCaseImplementationFailureHoldingProxy.h" - -@interface FBFailureProofTestCase () -@property (nonatomic, assign) BOOL didRegisterAXTestFailure; -@end @implementation FBFailureProofTestCase @@ -28,6 +22,26 @@ - (void)setUp self.shouldHaltWhenReceivesControl = NO; } +- (void)_recordIssue:(XCTIssue *)issue +{ + NSString *description = [NSString stringWithFormat:@"%@ (%@)", issue.compactDescription, issue.associatedError.description]; + [FBLogger logFmt:@"Issue type: %ld", issue.type]; + [self _enqueueFailureWithDescription:description + inFile:issue.sourceCodeContext.location.fileURL.path + atLine:issue.sourceCodeContext.location.lineNumber + // 5 == XCTIssueTypeUnmatchedExpectedFailure + expected:issue.type == 5]; +} + +- (void)_recordIssue:(XCTIssue *)issue forCaughtError:(id)error +{ + [self _recordIssue:issue]; +} + +- (void)recordIssue:(XCTIssue *)issue +{ + [self _recordIssue:issue]; +} /** Override 'recordFailureWithDescription' to not stop by failures. @@ -49,17 +63,7 @@ - (void)_enqueueFailureWithDescription:(NSString *)description expected:(BOOL)expected { [FBLogger logFmt:@"Enqueue Failure: %@ %@ %lu %d", description, filePath, (unsigned long)lineNumber, expected]; - const BOOL isPossibleDeadlock = ([description rangeOfString:@"Failed to get refreshed snapshot"].location != NSNotFound); - if (!isPossibleDeadlock) { - self.didRegisterAXTestFailure = YES; - } - else if (self.didRegisterAXTestFailure) { - self.didRegisterAXTestFailure = NO; // Reseting to NO to enable future deadlock detection - [[NSException exceptionWithName:FBApplicationDeadlockDetectedException - reason:@"Can't communicate with deadlocked application" - userInfo:nil] - raise]; - } + // TODO: Figure out which error types we want to escalate } @end diff --git a/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.h b/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.h deleted file mode 100644 index 8bf06b2a2..000000000 --- a/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -@class _XCTestCaseImplementation; - -NS_ASSUME_NONNULL_BEGIN - -/** - Class that can be used to proxy existing _XCTestCaseImplementation and - prevent currently running test from being terminated on any XCTest failure - */ -@interface FBXCTestCaseImplementationFailureHoldingProxy : NSProxy - -/** - Constructor for given existing _XCTestCaseImplementation instance - */ -+ (instancetype)proxyWithXCTestCaseImplementation:(_XCTestCaseImplementation *)internalImplementation; - -@end - -NS_ASSUME_NONNULL_END diff --git a/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.m b/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.m deleted file mode 100644 index 23f257416..000000000 --- a/WebDriverAgentLib/Utilities/FBXCTestCaseImplementationFailureHoldingProxy.m +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "FBXCTestCaseImplementationFailureHoldingProxy.h" - -#import - -@interface FBXCTestCaseImplementationFailureHoldingProxy () -@property (nonatomic, strong) _XCTestCaseImplementation *internalImplementation; -@end - -@implementation FBXCTestCaseImplementationFailureHoldingProxy - -+ (instancetype)proxyWithXCTestCaseImplementation:(_XCTestCaseImplementation *)internalImplementation -{ - FBXCTestCaseImplementationFailureHoldingProxy *proxy = [super alloc]; - proxy.internalImplementation = internalImplementation; - return proxy; -} - -- (id)forwardingTargetForSelector:(SEL)aSelector -{ - return self.internalImplementation; -} - -// This will prevent test from quiting on app crash or any other test failure -- (BOOL)shouldHaltWhenReceivesControl -{ - return NO; -} - -@end diff --git a/WebDriverAgentLib/WebDriverAgentLib.h b/WebDriverAgentLib/WebDriverAgentLib.h index df9b139ed..b8f85e98f 100644 --- a/WebDriverAgentLib/WebDriverAgentLib.h +++ b/WebDriverAgentLib/WebDriverAgentLib.h @@ -50,3 +50,4 @@ FOUNDATION_EXPORT const unsigned char WebDriverAgentLib_VersionString[]; #import #import #import +#import