Skip to content

Install fallback event handler before running tests#1523

Merged
jerryjrchen merged 4 commits intoswiftlang:mainfrom
jerryjrchen:push-lxxkqoqwknxy
Mar 5, 2026
Merged

Install fallback event handler before running tests#1523
jerryjrchen merged 4 commits intoswiftlang:mainfrom
jerryjrchen:push-lxxkqoqwknxy

Conversation

@jerryjrchen
Copy link
Contributor

@jerryjrchen jerryjrchen commented Feb 3, 2026

Swift Testing now participates in both directions of interoperability. Currently, this is opt-in via an environment variable at runtime.

Motivation:

Allows Swift Testing to handle foreign test events (e.g. XCTAssert).

Modifications:

Install fallback event handler before running tests.

Checklist:

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

@jerryjrchen jerryjrchen added this to the Swift 6.4.0 (main) milestone Feb 3, 2026
@jerryjrchen jerryjrchen self-assigned this Feb 3, 2026
@jerryjrchen jerryjrchen added the interoperability ↔️ Work related to Swift Testing and XCTest interoperability label Feb 3, 2026
if let abi {
let recordJSON = UnsafeRawBufferPointer(
start: recordJSONBaseAddress, count: recordJSONByteCount)
try! Self.handle(recordJSON, encodedWith: abi)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you talk about why you believe it's safe/appropriate to try! here? Would be nice to capture that in a comment (though not critical), but my main question is whether it's actually safe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I think I actually want to do some logging here instead of the try!. My initial intention was that we didn't want to let errors silently slip by because the handler failed to decode the message. I'm going to record an issue with the error (and add a test for that behaviour too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I came up with a somewhat clunky error message, but at the very least it should provide plenty of context for this rare failure mode.

Swift Testing now participates in both directions of interoperability.
Currently, this is opt-in via an environment variable at runtime.

This only implements the "complete" interop mode -- follow-up changes
will add interop configurability.

Test
@jerryjrchen jerryjrchen merged commit 3f4f1df into swiftlang:main Mar 5, 2026
27 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in [Swift Testing] Interoperability Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interoperability ↔️ Work related to Swift Testing and XCTest interoperability

Projects

Development

Successfully merging this pull request may close these issues.

3 participants