Enable exit test value capturing#1165
Conversation
This PR enables the value capture subfeature of exit tests and adds documentation for it. > [!WARNING] > Do not merge this PR unless/until [ST-NNNN](swiftlang/swift-evolution#2886) has been approved.
|
@swift-ci test |
|
@swift-ci test |
|
@swift-ci test |
|
@swift-ci test |
|
Waiting for #1208 before merging as it has ABI impact. |
|
@swift-ci test |
iamleeg
left a comment
There was a problem hiding this comment.
Just a few suggestions but looks good mostly.
| } | ||
| ``` | ||
|
|
||
| - Note: If you use this macro with a Swift compiler version lower than 6.3, it |
There was a problem hiding this comment.
I'd suggest "the macro" instead of "this macro" here, to be clear you're talking about that one rather than @Test which the snippet also uses.
There was a problem hiding this comment.
This language is the same as what we did for #expect(throws:). Did you want to change it there too?
There was a problem hiding this comment.
I meant to say "the expect(processExitsWith:) macro", not sure why that didn't come out. Anyway, if we're writing in the reference doc for a macro, "this macro" clearly refers to the one we're describing. In an article, and particularly one where we've just used two different macros in one example, there's no "this" binding.
| If a captured value is an argument to the current function or is `self`, its | ||
| type is inferred at compile time. Otherwise, explicitly specify the type of the |
There was a problem hiding this comment.
"…the compiler infers the value's type." to avoid passive voice.
| Every value you capture in an exit test must conform to [`Sendable`](https://developer.apple.com/documentation/swift/sendable) | ||
| and [`Codable`](https://developer.apple.com/documentation/swift/codable). Each | ||
| value is encoded by the parent process using [`encode(to:)`](https://developer.apple.com/documentation/swift/encodable/encode(to:)) | ||
| and is decoded by the child process [`init(from:)`](https://developer.apple.com/documentation/swift/decodable/init(from:)) | ||
| before being passed to the exit test body. |
There was a problem hiding this comment.
The parent process encodes each value using
encode(to:)and the child process decodes each value usinginit(from:)before passing them to the exit test body.
Feels worse somehow. Thoughts?
There was a problem hiding this comment.
How about:
The testing library encodes each value using
encode(to:)in the parent process, and decodes it usinginit(from:)in the child process, before passing it to the exit test body.
Because it's the testing library that actually does all of this.
Review recent changes in the exit test documentation. ### Motivation: @grynspan asked me to review #1165 but it was already merged by the time I got there, so here are my review suggestions as a fresh PR. ### Modifications: - Specified which macro we mean by "this macro" in the exit tests docs. - Removed instances of the passive voice. ### Checklist: - [X] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [X] If public symbols are renamed or modified, DocC references should be updated.
This PR enables the value capture subfeature of exit tests and adds documentation for it.
Resolves #1157.
Checklist: