[6.4.x] Support non-finite floats in exit test captures - #1842
Open
Kyle-Ye wants to merge 2 commits into
Open
Conversation
Kyle-Ye
commented
Aug 18, 2026
Contributor
- Explanation: Allows exit test capture lists to transport NaN and positive and negative infinity. Without this change, JSON encoding fails before the subprocess starts.
- Scope: Exit tests, captured-value JSON transport
- Issues: Exit test value capture fails for non-finite floating-point values #1836
- Original PRs: Support non-finite floats in exit test captures #1837
- Risk: Low. The non-conforming floating-point strategy is enabled only for the captured-value transport; other JSON call sites retain their existing behavior.
- Testing: A parameterized regression test covers NaN and positive and negative infinity and has been verified with Swift 6.4.
- Reviewers: @grynspan @stmontgomery
Allow exit test capture lists to round-trip NaN and positive and negative infinity. ### Motivation: Exit-test value capturing became available in Swift 6.3. Captured values are JSON-encoded in the parent process and decoded in the subprocess. The default JSON coding strategies reject non-finite floating-point values even though `Float` and `Double` satisfy the `Codable` and `Sendable` requirements for captured values. Fixes swiftlang#1836. ### Modifications: Configure matching non-conforming floating-point encoding and decoding strategies specifically for the exit-test captured-value transport, using an internal coding user-info key so other JSON call sites retain their default behavior. Use `"NaN"`, `"Infinity"`, and `"-Infinity"` as the JSON string representations, following conventions used by other JSON encoders. Add a parameterized regression test covering positive infinity, negative infinity, and NaN, including validation that their classification and sign survive the round trip. ### AI Disclosure: Codex was used to help investigate the exit-test capture path, research JSON prior art, and draft and refine the implementation, tests, and PR text. I reviewed the resulting changes and verified the regression test locally. ### Checklist: - [x] Code and documentation follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] No public symbols are renamed or modified, so no DocC references need updating. ### Future discussion I suggest this should also be cherry-picked into release/6.4 and release/6.3.
Kyle-Ye
requested review from
briancroom,
grynspan,
harlanhaskins,
jerryjrchen and
stmontgomery
as code owners
August 18, 2026 19:38
Contributor
Author
|
As discussed here, I'll wait for a future 6.4.1 release. cc @grynspan |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.