@@ -23,14 +23,16 @@ import Foundation
2323 /// - expected: An optional closure that returns a previously generated snapshot. When omitted,
2424 /// the library will automatically write a snapshot into your test file at the call sight of
2525 /// the assertion.
26- /// - file: The file where the assertion occurs. The default is the filename of the test case
27- /// where you call this function.
26+ /// - fileID: The file ID in which failure occurred. Defaults to the file ID of the test case in
27+ /// which this function was called.
28+ /// - file: The file in which failure occurred. Defaults to the file path of the test case in
29+ /// which this function was called.
2830 /// - function: The function where the assertion occurs. The default is the name of the test
2931 /// method where you call this function.
30- /// - line: The line where the assertion occurs. The default is the line number where you call
31- /// this function.
32- /// - column: The column where the assertion occurs. The default is the line column you call
33- /// this function.
32+ /// - line: The line number on which failure occurred. Defaults to the line number on which this
33+ /// function was called .
34+ /// - column: The column on which failure occurred. Defaults to the column on which this
35+ /// function was called .
3436 public func assertInlineSnapshot< Value> (
3537 of value: @autoclosure ( ) throws -> Value ? ,
3638 as snapshotting: Snapshotting < Value , String > ,
@@ -39,7 +41,8 @@ import Foundation
3941 timeout: TimeInterval = 5 ,
4042 syntaxDescriptor: InlineSnapshotSyntaxDescriptor = InlineSnapshotSyntaxDescriptor ( ) ,
4143 matches expected: ( ( ) -> String ) ? = nil ,
42- file: StaticString = #filePath,
44+ fileID: StaticString = #fileID,
45+ file filePath: StaticString = #filePath,
4346 function: StaticString = #function,
4447 line: UInt = #line,
4548 column: UInt = #column
@@ -70,15 +73,29 @@ import Foundation
7073 loaded. If a timeout is unavoidable, consider setting the " timeout " parameter of
7174 " assertInlineSnapshot " to a higher value.
7275 """ ,
73- file: file,
74- line: line
76+ fileID: fileID,
77+ filePath: filePath,
78+ line: line,
79+ column: column
7580 )
7681 return
7782 case . incorrectOrder, . interrupted, . invertedFulfillment:
78- recordIssue ( " Couldn't snapshot value " , file: file, line: line)
83+ recordIssue (
84+ " Couldn't snapshot value " ,
85+ fileID: fileID,
86+ filePath: filePath,
87+ line: line,
88+ column: column
89+ )
7990 return
8091 @unknown default :
81- recordIssue ( " Couldn't snapshot value " , file: file, line: line)
92+ recordIssue (
93+ " Couldn't snapshot value " ,
94+ fileID: fileID,
95+ filePath: filePath,
96+ line: line,
97+ column: column
98+ )
8299 return
83100 }
84101 }
@@ -88,7 +105,7 @@ import Foundation
88105 record != . missing || expected != nil
89106 else {
90107 // NB: Write snapshot state before calling `XCTFail` in case `continueAfterFailure = false`
91- inlineSnapshotState [ File ( path: file ) , default: [ ] ] . append (
108+ inlineSnapshotState [ File ( path: filePath ) , default: [ ] ] . append (
92109 InlineSnapshot (
93110 expected: expected,
94111 actual: actual,
@@ -119,8 +136,10 @@ import Foundation
119136
120137 Re-run " \( function) " to assert against the newly-recorded snapshot.
121138 """ ,
122- file: file,
123- line: line
139+ fileID: fileID,
140+ filePath: filePath,
141+ line: line,
142+ column: column
124143 )
125144 return
126145 }
@@ -131,8 +150,10 @@ import Foundation
131150 """
132151 No expected value to assert against.
133152 """ ,
134- file: file,
135- line: line
153+ fileID: fileID,
154+ filePath: filePath,
155+ line: line,
156+ column: column
136157 )
137158 return
138159 }
@@ -147,25 +168,34 @@ import Foundation
147168
148169 \( difference. indenting ( by: 2 ) )
149170 """ ,
150- file: file,
171+ fileID: fileID,
172+ file: filePath,
151173 line: line,
152174 column: column
153175 )
154176 } catch {
155- recordIssue ( " Threw error: \( error) " , file: file, line: line)
177+ recordIssue (
178+ " Threw error: \( error) " ,
179+ fileID: fileID,
180+ filePath: filePath,
181+ line: line,
182+ column: column
183+ )
156184 }
157185 }
158186 }
159187#else
160188 @available ( * , unavailable, message: " 'assertInlineSnapshot' requires 'swift-syntax' >= 509.0.0 " )
161189 public func assertInlineSnapshot< Value> (
162- of value: @autoclosure ( ) throws -> Value ,
190+ of value: @autoclosure ( ) throws -> Value ? ,
163191 as snapshotting: Snapshotting < Value , String > ,
164192 message: @autoclosure ( ) -> String = " " ,
193+ record isRecording: Bool ? = nil ,
165194 timeout: TimeInterval = 5 ,
166195 syntaxDescriptor: InlineSnapshotSyntaxDescriptor = InlineSnapshotSyntaxDescriptor ( ) ,
167196 matches expected: ( ( ) -> String ) ? = nil ,
168- file: StaticString = #filePath,
197+ fileID: StaticString = #fileID,
198+ file filePath: StaticString = #filePath,
169199 function: StaticString = #function,
170200 line: UInt = #line,
171201 column: UInt = #column
@@ -242,20 +272,23 @@ public struct InlineSnapshotSyntaxDescriptor: Hashable {
242272 ///
243273 /// - Parameters:
244274 /// - message: An optional description of the assertion, for inclusion in test results.
245- /// - file: The file where the assertion occurs. The default is the filename of the test case
246- /// where you call `assertInlineSnapshot`.
247- /// - line: The line where the assertion occurs. The default is the line number where you call
248- /// `assertInlineSnapshot`.
249- /// - column: The column where the assertion occurs. The default is the column where you call
250- /// `assertInlineSnapshot`.
275+ /// - fileID: The file ID in which failure occurred. Defaults to the file ID of the test case
276+ /// in which this function was called.
277+ /// - file: The file in which failure occurred. Defaults to the file path of the test case in
278+ /// which this function was called.
279+ /// - line: The line number on which failure occurred. Defaults to the line number on which
280+ /// this function was called.
281+ /// - column: The column on which failure occurred. Defaults to the column on which this
282+ /// function was called.
251283 public func fail(
252284 _ message: @autoclosure ( ) -> String = " " ,
253- file: StaticString ,
285+ fileID: StaticString ,
286+ file filePath: StaticString ,
254287 line: UInt ,
255288 column: UInt
256289 ) {
257290 var trailingClosureLine : Int ?
258- if let testSource = try ? testSource ( file: File ( path: file ) ) {
291+ if let testSource = try ? testSource ( file: File ( path: filePath ) ) {
259292 let visitor = SnapshotVisitor (
260293 functionCallLine: Int ( line) ,
261294 functionCallColumn: Int ( column) ,
@@ -267,8 +300,10 @@ public struct InlineSnapshotSyntaxDescriptor: Hashable {
267300 }
268301 recordIssue (
269302 message ( ) ,
270- file: file,
271- line: trailingClosureLine. map ( UInt . init) ?? line
303+ fileID: fileID,
304+ filePath: filePath,
305+ line: trailingClosureLine. map ( UInt . init) ?? line,
306+ column: column
272307 )
273308 }
274309
@@ -279,7 +314,8 @@ public struct InlineSnapshotSyntaxDescriptor: Hashable {
279314 @available ( * , unavailable, message: " 'assertInlineSnapshot' requires 'swift-syntax' >= 509.0.0 " )
280315 public func fail(
281316 _ message: @autoclosure ( ) -> String = " " ,
282- file: StaticString ,
317+ fileID: StaticString ,
318+ file filePath: StaticString ,
283319 line: UInt ,
284320 column: UInt
285321 ) {
0 commit comments