-
Notifications
You must be signed in to change notification settings - Fork 124
Change the semantics of Test.cancel()
.
#1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,7 @@ extension Test { | |
static func withCurrent<R>(_ test: Self, perform body: () async throws -> R) async rethrows -> R { | ||
var runtimeState = Runner.RuntimeState.current ?? .init() | ||
runtimeState.test = test | ||
runtimeState.testCase = nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks out-of-place, but it ensures that when we set the current test, we clear the current test case. This has no effect on third-party tests but ensures when we run nested tests of our own that they don't get their states intermingled (which breaks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. This is probably something we'd probably want even if we'd never sought to add test cancellation |
||
return try await Runner.RuntimeState.$current.withValue(runtimeState) { | ||
try await test.withCancellationHandling(body) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit tests no longer need to be concerned with
.testCaseCancelled
events.