@@ -50,12 +50,15 @@ extension Test.Attachment where AttachableValue == Data {
50
50
/// - preferredName: The preferred name of the attachment when writing it
51
51
/// to a test report or to disk. If `nil`, the name of the attachment is
52
52
/// 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.
54
56
///
55
57
/// - Throws: Any error that occurs attempting to read from `url`.
56
58
public init (
57
59
contentsOf url: URL ,
58
- named preferredName: String ? = nil
60
+ named preferredName: String ? = nil ,
61
+ sourceLocation: SourceLocation = #_sourceLocation
59
62
) async throws {
60
63
guard url. isFileURL else {
61
64
// TODO: network URLs?
@@ -87,10 +90,10 @@ extension Test.Attachment where AttachableValue == Data {
87
90
return ( preferredName as NSString ) . appendingPathExtension ( " tgz " ) ?? preferredName
88
91
} ( )
89
92
90
- try await self . init ( Data ( compressedContentsOfDirectoryAt: url) , named: preferredName)
93
+ try await self . init ( Data ( compressedContentsOfDirectoryAt: url) , named: preferredName, sourceLocation : sourceLocation )
91
94
} else {
92
95
// 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 )
94
97
}
95
98
}
96
99
}
0 commit comments