Skip to content

Commit 0fc58d1

Browse files
committed
Need to preserve attachment source location info
1 parent deee757 commit 0fc58d1

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Sources/Testing/ABI/Encoded/ABI.EncodedAttachment.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ extension ABI {
6060
/// - Warning: Inline attachment content is not yet part of the JSON schema.
6161
var _bytes: Bytes?
6262

63+
/// The source location where this attachment was created.
64+
///
65+
/// - Warning: Attachment source locations are not yet part of the JSON
66+
/// schema.
67+
var _sourceLocation: SourceLocation?
68+
6369
init(encoding attachment: borrowing Attachment<AnyAttachable>, in eventContext: borrowing Event.Context) {
6470
path = attachment.fileSystemPath
6571
_preferredName = attachment.preferredName
@@ -73,6 +79,8 @@ extension ABI {
7379
return nil
7480
}
7581
}
82+
83+
_sourceLocation = attachment.sourceLocation
7684
}
7785

7886
/// A structure representing the bytes of an attachment.

Sources/Testing/Events/Event.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ extension Event {
289289
Issue(event)?.record()
290290
case .valueAttached:
291291
if let attachment = event.attachment {
292-
Attachment.record(attachment)
292+
Attachment.record(attachment, sourceLocation: attachment._sourceLocation ?? .__here())
293293
}
294294
default:
295295
// Not handled here.

Tests/TestingTests/EventTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ private func MockXCTAttachmentAdd(_ string: String, named name: String) {
182182
}
183183

184184
@Test func `Attachment is passed to fallback event handler`() async {
185+
MockXCTAttachmentAdd("0123456789", named: "numbers.txt")
185186
await confirmation("Attachment recorded") { valueAttached in
186187
var configuration = Configuration()
187188
configuration.eventHandler = { event, _ in

0 commit comments

Comments
 (0)