Skip to content

Commit

Permalink
makeTable
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Oct 18, 2024
1 parent 10c4eb5 commit b643574
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions .github/actions/test-summary/make-summary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ let document = try XMLDocument(contentsOf: junit)
let testCases = try document.nodes(forXPath: "//testcase")
let failures = try document.nodes(forXPath: "//failure/..")

let total = testCases.count
let failed = failures.count
let passed = total - failed
let skipped = 0

print("""
<table>
<tr><td></td><td>Tests</td><td><b>Passed</b> ✅</td><td>Skipped ⏭️</td><td>Failed ❌</td></tr>
<tr><td>\(junit.lastPathComponent)</td><td>\(total) ran</td><td>\(passed) passed</td><td>\(skipped) skipped</td><td>\(failed) failed</td></tr>
</table>
""")
let table = makeTable(
total: testCases.count,
failed: failures.count,
passed: testCases.count - failures.count
)
print(table)

for node in failures {

Expand All @@ -43,3 +38,17 @@ for node in failures {

print(messages.joined(separator: ". "))
}

func makeTable(
total: Int,
failed: Int,
passed: Int,
skipped: Int = 0
) -> String {
"""
<table>
<tr><td></td><td><b>Tests</b></td><td><b>Passed</b> ✅</td><td><b>Skipped</b> ⏭️</td><td><b>Failed</b> ❌</td></tr>
<tr><td>\(junit.lastPathComponent)</td><td>\(total) ran</td><td>\(passed) passed</td><td>\(skipped) skipped</td><td>\(failed) failed</td></tr>
</table>
"""
}

0 comments on commit b643574

Please sign in to comment.