From b643574e10cfcfb022c1d0d3695daaeec9d25b1d Mon Sep 17 00:00:00 2001 From: Simon Whitty Date: Sat, 19 Oct 2024 09:42:11 +1100 Subject: [PATCH] makeTable --- .../actions/test-summary/make-summary.swift | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/actions/test-summary/make-summary.swift b/.github/actions/test-summary/make-summary.swift index f7d27780..49f3224b 100755 --- a/.github/actions/test-summary/make-summary.swift +++ b/.github/actions/test-summary/make-summary.swift @@ -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(""" - - - -
TestsPassedSkipped ⏭️Failed ❌
\(junit.lastPathComponent)\(total) ran\(passed) passed\(skipped) skipped\(failed) failed
-""") +let table = makeTable( + total: testCases.count, + failed: failures.count, + passed: testCases.count - failures.count +) +print(table) for node in failures { @@ -43,3 +38,17 @@ for node in failures { print(messages.joined(separator: ". ")) } + +func makeTable( + total: Int, + failed: Int, + passed: Int, + skipped: Int = 0 +) -> String { + """ + + + +
TestsPassedSkipped ⏭️Failed
\(junit.lastPathComponent)\(total) ran\(passed) passed\(skipped) skipped\(failed) failed
+ """ +} \ No newline at end of file