Skip to content

Commit

Permalink
Improved recording by leveraging inline snapshot removal (#21)
Browse files Browse the repository at this point in the history
* wip

* bump
  • Loading branch information
stephencelis authored Apr 8, 2024
1 parent 90e38ee commit 5c4a1b9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "5b0c434778f2c1a4c9b5ebdb8682b28e84dd69bd",
"version" : "1.15.4"
"revision" : "625ccca8570773dd84a34ee51a81aa2bc5a4f97a",
"version" : "1.16.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-syntax", "509.0.0"..<"511.0.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.15.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.16.0"),
],
targets: [
.target(
Expand Down
59 changes: 41 additions & 18 deletions Sources/MacroTesting/AssertMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,21 @@ public func assertMacro(
)
} else if diagnosedSource != nil {
offset += 1
InlineSnapshotSyntaxDescriptor(
trailingClosureLabel: "diagnostics",
trailingClosureOffset: offset
)
.fail(
"Expected diagnostics, but there were none",
assertInlineSnapshot(
of: nil,
as: ._lines,
message: """
Diagnostic output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
Difference: …
""",
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
deprecatedTrailingClosureLabels: ["matches"],
trailingClosureLabel: "diagnostics",
trailingClosureOffset: offset
),
matches: diagnosedSource,
file: file,
function: function,
line: line,
column: column
)
Expand Down Expand Up @@ -299,13 +307,20 @@ public func assertMacro(
)
} else if fixedSource != nil {
offset += 1
InlineSnapshotSyntaxDescriptor(
trailingClosureLabel: "fixes",
trailingClosureOffset: offset
)
.fail(
"Expected fix-its, but there were none",
assertInlineSnapshot(
of: nil,
as: ._lines,
message: """
Fixed output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
Difference: …
""",
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
trailingClosureLabel: "fixes",
trailingClosureOffset: offset
),
matches: fixedSource,
file: file,
function: function,
line: line,
column: column
)
Expand Down Expand Up @@ -333,13 +348,21 @@ public func assertMacro(
)
} else if expandedSource != nil {
offset += 1
InlineSnapshotSyntaxDescriptor(
trailingClosureLabel: "expansion",
trailingClosureOffset: offset
)
.fail(
"Expected macro expansion, but there was none",
assertInlineSnapshot(
of: nil,
as: ._lines,
message: """
Expanded output (\(newPrefix)) differed from expected output (\(oldPrefix)). \
Difference: …
""",
syntaxDescriptor: InlineSnapshotSyntaxDescriptor(
deprecatedTrailingClosureLabels: ["matches"],
trailingClosureLabel: "expansion",
trailingClosureOffset: offset
),
matches: expandedSource,
file: file,
function: function,
line: line,
column: column
)
Expand Down

0 comments on commit 5c4a1b9

Please sign in to comment.