Skip to content

Enable exit test value capturing#1165

Merged
grynspan merged 6 commits into
mainfrom
jgrynspan/enable-exit-test-value-capturing
Jul 23, 2025
Merged

Enable exit test value capturing#1165
grynspan merged 6 commits into
mainfrom
jgrynspan/enable-exit-test-value-capturing

Conversation

@grynspan

@grynspan grynspan commented Jun 19, 2025

Copy link
Copy Markdown
Contributor

This PR enables the value capture subfeature of exit tests and adds documentation for it.

Resolves #1157.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • 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.

> [!WARNING]
> Do not merge this PR unless/until [ST-NNNN](swiftlang/swift-evolution#2886) has been approved.
@grynspan grynspan added this to the Swift 6.x milestone Jun 19, 2025
@grynspan grynspan self-assigned this Jun 19, 2025
@grynspan grynspan added documentation 📚 Improvements or additions to documentation enhancement New feature or request public-api Affects public API exit-tests ☠️ Work related to exit tests exit-test-capture-lists 🥍 Work related to exit test capture lists labels Jun 19, 2025
@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan

grynspan commented Jul 8, 2025

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan grynspan changed the title [DNM] Enable exit test value capturing Enable exit test value capturing Jul 21, 2025
@grynspan grynspan marked this pull request as ready for review July 21, 2025 15:45
@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan

Copy link
Copy Markdown
Contributor Author

Waiting for #1208 before merging as it has ABI impact.

@grynspan

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 802d8f8 into main Jul 23, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/enable-exit-test-value-capturing branch July 23, 2025 12:47

@iamleeg iamleeg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few suggestions but looks good mostly.

}
```

- Note: If you use this macro with a Swift compiler version lower than 6.3, it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This language is the same as what we did for #expect(throws:). Did you want to change it there too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +113 to +114
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"…the compiler infers the value's type." to avoid passive voice.

Comment on lines +128 to +132
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passive voice here, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent process encodes each value using encode(to:) and the child process decodes each value using init(from:) before passing them to the exit test body.

Feels worse somehow. Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

The testing library encodes each value using encode(to:) in the parent process, and decodes it using init(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.

grynspan pushed a commit that referenced this pull request Jan 19, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📚 Improvements or additions to documentation enhancement New feature or request exit-test-capture-lists 🥍 Work related to exit test capture lists exit-tests ☠️ Work related to exit tests public-api Affects public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exit tests should be able to capture values

4 participants