Skip to content

Commit 101068a

Browse files
committed
[Debug] Add snapshot diff output for CI debugging
1 parent 6445db1 commit 101068a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Plugins/BridgeJS/Tests/BridgeJSToolTests/SnapshotTesting.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ func assertSnapshot(
3232
#expect(ok, buildComment(), sourceLocation: sourceLocation)
3333
if !ok {
3434
try input.write(to: URL(fileURLWithPath: actualFilePath))
35+
// Print diff for CI debugging
36+
let expectedLines = existingSnapshot.split(separator: "\n", omittingEmptySubsequences: false)
37+
let actualStr = String(data: input, encoding: .utf8)!
38+
let actualLines = actualStr.split(separator: "\n", omittingEmptySubsequences: false)
39+
let maxLines = max(expectedLines.count, actualLines.count)
40+
for i in 0..<maxLines {
41+
let exp = i < expectedLines.count ? String(expectedLines[i]) : "<missing>"
42+
let act = i < actualLines.count ? String(actualLines[i]) : "<missing>"
43+
if exp != act {
44+
print("SNAPSHOT DIFF line \(i + 1):")
45+
print(" expected: \(exp)")
46+
print(" actual: \(act)")
47+
}
48+
}
49+
if expectedLines.count != actualLines.count {
50+
print("SNAPSHOT DIFF line count: expected=\(expectedLines.count) actual=\(actualLines.count)")
51+
}
3552
}
3653
} else {
3754
try input.write(to: snapshotPath)

0 commit comments

Comments
 (0)