Skip to content

Commit 8273f0e

Browse files
committed
Update attach() -> record()
1 parent b35dcb6 commit 8273f0e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

proposals/testing/NNNN-attachments.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,15 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
9999
/// disk.
100100
///
101101
/// An attachment can only be attached once.
102-
public static func attach(_ attachment: consuming Self, sourceLocation: SourceLocation = #_sourceLocation)
102+
public static func record(_ attachment: consuming Self, sourceLocation: SourceLocation = #_sourceLocation)
103103

104104
/// Attach a value to the current test.
105105
///
106106
/// - Parameters:
107107
/// - attachableValue: The value to attach.
108+
/// - preferredName: The preferred name of the attachment when writing it to
109+
/// a test report or to disk. If `nil`, the testing library attempts to
110+
/// derive a reasonable filename for the attached value.
108111
/// - sourceLocation: The source location of the call to this function.
109112
///
110113
/// When attaching a value of a type that does not conform to both
@@ -119,7 +122,7 @@ public struct Attachment<AttachableValue>: ~Copyable where AttachableValue: Atta
119122
/// attaches it to the current test.
120123
///
121124
/// An attachment can only be attached once.
122-
public static func attach(_ attachment: consuming AttachableValue, sourceLocation: SourceLocation = #_sourceLocation)
125+
public static func record(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation)
123126

124127
/// Call a function and pass a buffer representing the value of this
125128
/// instance's ``attachableValue-2tnj5`` property to it.
@@ -153,10 +156,11 @@ conform:
153156
/// A protocol describing a type that can be attached to a test report or
154157
/// written to disk when a test is run.
155158
///
156-
/// To attach an attachable value to a test report or test run output, use it to
157-
/// initialize a new instance of ``Attachment``, then call
158-
/// ``Attachment/attach(_:sourceLocation:)``. An attachment can only be attached
159-
/// once.
159+
/// To attach an attachable value to a test, pass it to ``Attachment/record(_:named:sourceLocation:)``.
160+
/// To further configure an attachable value before you attach it, use it to
161+
/// initialize an instance of ``Attachment`` and set its properties before
162+
/// passing it to ``Attachment/record(_:sourceLocation:)``. An attachable
163+
/// value can only be attached to a test once.
160164
///
161165
/// The testing library provides default conformances to this protocol for a
162166
/// variety of standard library types. Most user-defined types do not need to
@@ -245,10 +249,11 @@ that refines `Attachable`:
245249
/// written to disk when a test is run and which contains another value that it
246250
/// stands in for.
247251
///
248-
/// To attach an attachable value to a test report or test run output, use it to
249-
/// initialize a new instance of ``Attachment``, then call
250-
/// ``Attachment/attach(_:sourceLocation:)``. An attachment can only be attached
251-
/// once.
252+
/// To attach an attachable value to a test, pass it to ``Attachment/record(_:named:sourceLocation:)``.
253+
/// To further configure an attachable value before you attach it, use it to
254+
/// initialize an instance of ``Attachment`` and set its properties before
255+
/// passing it to ``Attachment/record(_:sourceLocation:)``. An attachable
256+
/// value can only be attached to a test once.
252257
///
253258
/// A type can conform to this protocol if it represents another type that
254259
/// cannot directly conform to ``Attachable``, such as a non-final class or a
@@ -452,10 +457,10 @@ version too.
452457
allows an implementation (such as that of `Encodable & Attachable`) to add a
453458
path extension to the filename specified by the test author if needed.
454459
455-
- Making the `Attachment.attach(_:sourceLocation:)` methods a single instance
456-
method of `Attachment` named `attach()`: this was in the initial pitch but the
457-
community discussed several more ergonomic options and we chose
458-
`Attachment.attach(_:sourceLocation:)` instead.
460+
- Making the `Attachment.record(_:[named:]sourceLocation:)` methods a single
461+
instance method of `Attachment` named `attach()`: this was in the initial
462+
pitch but the community discussed several more ergonomic options and we chose
463+
`Attachment.record(_:sourceLocation:)` instead.
459464
460465
## Acknowledgments
461466

0 commit comments

Comments
 (0)