Skip to content

Commit 938057e

Browse files
committed
Make wasDeferred DEBUG-only
1 parent b863106 commit 938057e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Sources/Testing/Events/Event.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ public struct Event: Sendable {
191191
/// The instant at which the event occurred.
192192
public var instant: Test.Clock.Instant
193193

194+
#if DEBUG
194195
/// Whether or not this event was deferred.
195196
///
196197
/// A deferred event is handled significantly later than when was posted.
197198
///
198199
/// We currently use this property in our tests, but do not expose it as API
199200
/// or SPI. We can expose it in the future if tools need it.
200201
var wasDeferred: Bool = false
202+
#endif
201203

202204
/// Initialize an instance of this type.
203205
///

Sources/Testing/Traits/AttachmentSavingTrait.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,11 @@ extension AttachmentSavingTrait: TestScoping {
200200

201201
// Finally issue the attachment-recorded events that we deferred.
202202
let eventContext = Event.Context(test: test, testCase: testCase, configuration: configuration)
203-
for var event in context.deferredEvents {
203+
for event in context.deferredEvents {
204+
#if DEBUG
205+
var event = event
204206
event.wasDeferred = true
207+
#endif
205208
configuration.eventHandler(event, eventContext)
206209
}
207210
}

Tests/TestingTests/Traits/AttachmentSavingTraitTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ struct `AttachmentSavingTrait tests` {
2323
case .issueRecorded:
2424
issueRecorded()
2525
case let .valueAttached(attachment):
26+
#if DEBUG
2627
if trait != nil {
2728
#expect(event.wasDeferred)
2829
}
30+
#endif
2931
if let expectedPreferredName {
3032
#expect(attachment.preferredName == expectedPreferredName)
3133
}

0 commit comments

Comments
 (0)