Skip to content

Decode EncodedEvent -> Event#1684

Open
jerryjrchen wants to merge 2 commits intoswiftlang:mainfrom
jerryjrchen:decode-encoded-event
Open

Decode EncodedEvent -> Event#1684
jerryjrchen wants to merge 2 commits intoswiftlang:mainfrom
jerryjrchen:decode-encoded-event

Conversation

@jerryjrchen
Copy link
Copy Markdown
Contributor

@jerryjrchen jerryjrchen commented Apr 21, 2026

Motivation:

Enables re-use of EncodedEvent decoding logic for tools support interop. Today, corelibs XCTest manually re-defines the

Resolves rdar://175287183

Modifications:

  • Implement decoding EncodedEvent -> Event

  • Test common decoding scenarios, included decoding issueRecorded and valueAttached event kinds

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

### Motivation:

Enables re-use of EncodedEvent decoding logic for tools support interop.
Today, corelibs XCTest manually re-defines the 

Resolves rdar://175287183

### Modifications:

* Implement decoding EncodedEvent -> Event

* Test common decoding scenarios, included decoding issueRecorded and
  valueAttached event kinds
@jerryjrchen jerryjrchen added this to the Swift 6.4.0 (main) milestone Apr 21, 2026
@jerryjrchen jerryjrchen self-assigned this Apr 21, 2026
@jerryjrchen jerryjrchen added the enhancement New feature or request label Apr 21, 2026
@jerryjrchen jerryjrchen requested a review from grynspan as a code owner April 21, 2026 22:30
@jerryjrchen jerryjrchen requested a review from briancroom as a code owner April 21, 2026 22:30
@jerryjrchen jerryjrchen added the tools integration 🛠️ Integration of swift-testing into tools/IDEs label Apr 21, 2026
@jerryjrchen jerryjrchen added the interoperability ↔️ Work related to Swift Testing and XCTest interoperability label Apr 21, 2026
@jerryjrchen jerryjrchen moved this from Backlog to In review in [Swift Testing] Interoperability Apr 22, 2026
""")
let decoded = try #require(Event(decoding: event))

guard case .issueRecorded(let issue) = decoded.kind else {
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.

I wasn't sure if there was a nicer way of checking the enum case for kind since this enum has associated values

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.

This is how we do it for the moment.

//

@testable @_spi(ForToolsIntegrationOnly) import Testing
#if canImport(Foundation)
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.

Drive-by change?

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.

Yeah, realised I didn't need the import in my earlier change after writing the tests in this one. I can leave it out though

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.

It's fine, just helps to explain this sort of thing in the PR. :)

@jerryjrchen jerryjrchen requested a review from grynspan April 22, 2026 23:10
This makes it easier to handle new event types and simplifies (?) the
logic for managing currently support event kinds.

No functional change in behaviour. This technically enables exit tests
to handle .testSkipped event kinds, but this cannot occur in practise.
Comment on lines +193 to +194
/// ``testID`` and ``testCaseID`` are always `nil` because we need information
/// from the associated `ABI.EncodedTest` to properly decode those values.
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.

So it'll just be follow-on work to fill in these missing property values, I take it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request interoperability ↔️ Work related to Swift Testing and XCTest interoperability tools integration 🛠️ Integration of swift-testing into tools/IDEs

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants