swiftlang / swift-testing

A modern, expressive testing package for Swift
Apache License 2.0
1.81k stars 77 forks source link

Provide an opt-out conditional for lazy attachment encoding. #811

Closed grynspan closed 2 weeks ago

grynspan commented 2 weeks ago

This PR provides a compile-time conditional, SWT_NO_LAZY_ATTACHMENTS, which when set causes Swift Testing's new experimental attachments feature to always eagerly encode/serialize/whatever attachments even if they're copyable and sendable.

We anticipate using this functionality in Embedded Swift in the future. Note that support for Embedded Swift is not (yet!) a planned feature.

"Why not make Attachment generic?"

I've got a separate branch that tries to do this. It has a significantly more complex implementation and is brittle because we need to type-erase the attachable value in order to pass it into the event-handling machinery (which entails having a bunch of special-casing since any Test.Attachable does not conform to Test.Attachable.) Attachment is already meant to represent a type-erased Attachable value.

Checklist:

grynspan commented 2 weeks ago

@swift-ci test