Skip to content

Commit e432ce2

Browse files
committed
URL inits need source location
1 parent 28e5bba commit e432ce2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Sources/Overlays/_Testing_Foundation/Attachments/Test.Attachment+URL.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ extension Test.Attachment where AttachableValue == Data {
5050
/// - preferredName: The preferred name of the attachment when writing it
5151
/// to a test report or to disk. If `nil`, the name of the attachment is
5252
/// derived from the last path component of `url`.
53-
/// - sourceLocation: The source location of the attachment.
53+
/// - sourceLocation: The source location of the call to this initializer.
54+
/// This value is used when recording issues associated with the
55+
/// attachment.
5456
///
5557
/// - Throws: Any error that occurs attempting to read from `url`.
5658
public init(
5759
contentsOf url: URL,
58-
named preferredName: String? = nil
60+
named preferredName: String? = nil,
61+
sourceLocation: SourceLocation = #_sourceLocation
5962
) async throws {
6063
guard url.isFileURL else {
6164
// TODO: network URLs?
@@ -87,10 +90,10 @@ extension Test.Attachment where AttachableValue == Data {
8790
return (preferredName as NSString).appendingPathExtension("tgz") ?? preferredName
8891
}()
8992

90-
try await self.init(Data(compressedContentsOfDirectoryAt: url), named: preferredName)
93+
try await self.init(Data(compressedContentsOfDirectoryAt: url), named: preferredName, sourceLocation: sourceLocation)
9194
} else {
9295
// Load the file.
93-
try self.init(Data(contentsOf: url, options: [.mappedIfSafe]), named: preferredName)
96+
try self.init(Data(contentsOf: url, options: [.mappedIfSafe]), named: preferredName, sourceLocation: sourceLocation)
9497
}
9598
}
9699
}

0 commit comments

Comments
 (0)