Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Feb 12, 2025

This PR plumbs the schema version (0 or 1) through the Swift types and functions that produce our JSON output, allowing them to change behaviour based on which version is in use.

As a proof-of-concept as much as anything else, this PR also adds an (unsupported) _tags field to the JSON output for a test record, but only with ABI version 1.

I've split this PR into two commits: the first plumbs the version through as an integer argument, while the second uses the type system to represent different ABI versions. The latter uses a protocol that we can extend so that different ABI versions have differing behaviours (although that's too coarse-grained for things like _tags.)

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 plumbs the schema version (0 or 1) through the Swift types and functions
that produce our JSON output, allowing them to change behaviour based on which
version is in use.

As a proof-of-concept as much as anything else, this PR also adds an
(unsupported) `_tags` field to the JSON output for a test record, but only with
ABI version 1.
@grynspan grynspan added enhancement New feature or request tools integration 🛠️ Integration of swift-testing into tools/IDEs labels Feb 12, 2025
@grynspan grynspan added this to the Swift 6.x milestone Feb 12, 2025
@grynspan grynspan self-assigned this Feb 12, 2025
return version.eventHandler(encodeAsJSONLines: encodeAsJSONLines, forwardingTo: targetEventHandler)
}

return switch versionNumber {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could refactor this switch to produce an any ABI.Version.Type, or even move it into ABI as ABI.version(withVersionNumber:), but that would require returning an existential any which would preclude its eventual use in Embedded Swift.

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit 7efce39 into main Feb 19, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/plumb-version-into-abi-json-record-structs branch February 19, 2025 15:23
stmontgomery added a commit that referenced this pull request Sep 6, 2025
…ize relevant content (#1287)

This PR formally defines an "experimental" event stream version (named
`ABI.ExperimentalVersion`) which represents content that is considered
experimental. It then adopts the new experimental version in several
places to conditionalize the inclusion of fields on event stream models
which are not yet officially included in any defined, supported version.
Finally, it uses this new version everywhere that intentionally always
uses the _highest experimental_ version, such as the exit test back
channel and the [recently-added](#1253) experimental console output
recorder.

### Motivation:

The event stream now has an established versioning system (as of #956)
and can easily conditionalize content based on version. As a general
rule, we prefer to exclude content which has not gone through Swift
Evolution review when delivering data to event stream consumers which
expect to receive content from a supported version. The fields this PR
conditionalizes have underscore prefixes and have code-level
documentation indicating their unofficial-ness, but the fact that they
are included at all in supported/non-experimental version streams could
lead to misuse or unintentional breakages in the future if the names or
semantics of these fields change.

### 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

enhancement New feature or request tools integration 🛠️ Integration of swift-testing into tools/IDEs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants