Skip to content

Make ExitTestArtifacts.observedValues properly sendable. #781

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

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/Testing/ExitTests/ExitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct ExitTest: Sendable, ~Copyable {
/// Key paths are not sendable because the properties they refer to may or may
/// not be, so this property needs to be `nonisolated(unsafe)`. It is safe to
/// use it in this fashion because `ExitTestArtifacts` is sendable.
fileprivate nonisolated(unsafe) var _observedValues = [PartialKeyPath<ExitTestArtifacts>]()
fileprivate var _observedValues = [any PartialKeyPath<ExitTestArtifacts> & Sendable]()

/// Key paths representing results from within this exit test that should be
/// observed and returned to the caller.
Expand All @@ -56,7 +56,7 @@ public struct ExitTest: Sendable, ~Copyable {
/// Within a child process running an exit test, the value of this property is
/// otherwise unspecified.
@_spi(ForToolsIntegrationOnly)
public var observedValues: [PartialKeyPath<ExitTestArtifacts>] {
public var observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] {
get {
var result = _observedValues
if !result.contains(\.exitCondition) { // O(n), but n <= 3 (no Set needed)
Expand Down Expand Up @@ -237,7 +237,7 @@ extension ExitTest {
/// convention.
func callExitTest(
exitsWith expectedExitCondition: ExitCondition,
observing observedValues: [PartialKeyPath<ExitTestArtifacts>],
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable],
expression: __Expression,
comments: @autoclosure () -> [Comment],
isRequired: Bool,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Testing/Expectations/Expectation+Macro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ public macro require<R>(
@discardableResult
@freestanding(expression) public macro expect(
exitsWith expectedExitCondition: ExitCondition,
observing observedValues: [PartialKeyPath<ExitTestArtifacts>] = [],
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] = [],
_ comment: @autoclosure () -> Comment? = nil,
sourceLocation: SourceLocation = #_sourceLocation,
performing expression: @convention(thin) () async throws -> Void
Expand Down Expand Up @@ -630,7 +630,7 @@ public macro require<R>(
@discardableResult
@freestanding(expression) public macro require(
exitsWith expectedExitCondition: ExitCondition,
observing observedValues: [PartialKeyPath<ExitTestArtifacts>] = [],
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable] = [],
_ comment: @autoclosure () -> Comment? = nil,
sourceLocation: SourceLocation = #_sourceLocation,
performing expression: @convention(thin) () async throws -> Void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ public func __checkClosureCall<R>(
@_spi(Experimental)
public func __checkClosureCall(
exitsWith expectedExitCondition: ExitCondition,
observing observedValues: [PartialKeyPath<ExitTestArtifacts>],
observing observedValues: [any PartialKeyPath<ExitTestArtifacts> & Sendable],
performing body: @convention(thin) () -> Void,
expression: __Expression,
comments: @autoclosure () -> [Comment],
Expand Down