Created
August 7, 2018 11:50
-
-
Save Kuniwak/e3284f11c371b1c8e44e0d51387d91ee to your computer and use it in GitHub Desktop.
Workaround for XCTContext.runActivity on AppCode.
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
import _SwiftXCTestOverlayShims | |
public extension XCTContext { | |
// XXX: This is for AppCode. The original of runActivity have been failed on only AppCode. | |
// This cause is __XCTContextShouldStartActivity, it returns true when it is called on Xcode, but not on AppCode. | |
public class func runActivityPatched<Result>(named name: String, block: (XCTActivity) throws -> Result) rethrows -> Result { | |
let context = _XCTContextCurrent() | |
return try autoreleasepool { | |
let activity = _XCTContextWillStartActivity(context, name, XCTActivityTypeUserCreated) | |
defer { | |
_XCTContextDidFinishActivity(context, activity) | |
} | |
return try block(activity) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment