Skip to content

Commit 5c4a1b9

Browse files
authored
Improved recording by leveraging inline snapshot removal (#21)
* wip * bump
1 parent 90e38ee commit 5c4a1b9

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
],
1919
dependencies: [
2020
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"511.0.0"),
21-
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.15.0"),
21+
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.16.0"),
2222
],
2323
targets: [
2424
.target(

Sources/MacroTesting/AssertMacro.swift

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,21 @@ public func assertMacro(
235235
)
236236
} else if diagnosedSource != nil {
237237
offset += 1
238-
InlineSnapshotSyntaxDescriptor(
239-
trailingClosureLabel: "diagnostics",
240-
trailingClosureOffset: offset
241-
)
242-
.fail(
243-
"Expected diagnostics, but there were none",
238+
assertInlineSnapshot(
239+
of: nil,
240+
as: ._lines,
241+
message: """
242+
Diagnostic output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
243+
Difference: …
244+
""",
245+
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
246+
deprecatedTrailingClosureLabels: ["matches"],
247+
trailingClosureLabel: "diagnostics",
248+
trailingClosureOffset: offset
249+
),
250+
matches: diagnosedSource,
244251
file: file,
252+
function: function,
245253
line: line,
246254
column: column
247255
)
@@ -299,13 +307,20 @@ public func assertMacro(
299307
)
300308
} else if fixedSource != nil {
301309
offset += 1
302-
InlineSnapshotSyntaxDescriptor(
303-
trailingClosureLabel: "fixes",
304-
trailingClosureOffset: offset
305-
)
306-
.fail(
307-
"Expected fix-its, but there were none",
310+
assertInlineSnapshot(
311+
of: nil,
312+
as: ._lines,
313+
message: """
314+
Fixed output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
315+
Difference: …
316+
""",
317+
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
318+
trailingClosureLabel: "fixes",
319+
trailingClosureOffset: offset
320+
),
321+
matches: fixedSource,
308322
file: file,
323+
function: function,
309324
line: line,
310325
column: column
311326
)
@@ -333,13 +348,21 @@ public func assertMacro(
333348
)
334349
} else if expandedSource != nil {
335350
offset += 1
336-
InlineSnapshotSyntaxDescriptor(
337-
trailingClosureLabel: "expansion",
338-
trailingClosureOffset: offset
339-
)
340-
.fail(
341-
"Expected macro expansion, but there was none",
351+
assertInlineSnapshot(
352+
of: nil,
353+
as: ._lines,
354+
message: """
355+
Expanded output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
356+
Difference: …
357+
""",
358+
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
359+
deprecatedTrailingClosureLabels: ["matches"],
360+
trailingClosureLabel: "expansion",
361+
trailingClosureOffset: offset
362+
),
363+
matches: expandedSource,
342364
file: file,
365+
function: function,
343366
line: line,
344367
column: column
345368
)

0 commit comments

Comments
 (0)