Skip to content

Commit 2e9ee80

Browse files
marcelofabriniilohlin
authored andcommitted
Attach recorded snapshot (pointfreeco#586)
1 parent 620ae84 commit 2e9ee80

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/SnapshotTesting/AssertSnapshot.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ public func verifySnapshot<Value, Format>(
235235

236236
guard !recording, fileManager.fileExists(atPath: snapshotFileUrl.path) else {
237237
try snapshotting.diffing.toData(diffable).write(to: snapshotFileUrl)
238+
#if !os(Linux) && !os(Windows)
239+
if ProcessInfo.processInfo.environment.keys.contains("__XCODE_BUILT_PRODUCTS_DIR_PATHS") {
240+
XCTContext.runActivity(named: "Attached Recorded Snapshot") { activity in
241+
let attachment = XCTAttachment(contentsOfFile: snapshotFileUrl)
242+
activity.add(attachment)
243+
}
244+
}
245+
#endif
246+
238247
return recording
239248
? """
240249
Record mode is on. Turn record mode off and re-run "\(testName)" to test against the newly-recorded snapshot.

0 commit comments

Comments
 (0)