| 1 | | import Foundation |
| 2 | | |
| 3 | | /// Every file of a run without coverage, including its available or empty test results. |
| 4 | | /// Values only; writing them is the command's job. |
| 5 | | public struct UnavailableSite: Sendable { |
| 6 | | public let files: [CoverageSite.File] |
| 7 | | |
| 8 | | /// - Parameter date: when the run was built; recorded in `totals.json`. |
| 9 | | public init( |
| 10 | | title: String, reason: String, commit: String?, subject: String?, date: Date, |
| 11 | | links: UnavailableLinks = UnavailableLinks(), results: TestResults? = nil |
| 12 | 4 | ) throws { |
| 13 | 4 | let page = UnavailablePage( |
| 14 | 4 | title: title, reason: reason, commit: commit, subject: subject, links: links) |
| 15 | 4 | let results = results ?? TestResults(merging: []) |
| 16 | 4 | let totals = RunTotals( |
| 17 | 4 | commit: commit, subject: subject, date: date, tests: results.counts, files: [], |
| 18 | 4 | unavailable: reason, hasTestsPage: true, |
| 19 | 4 | testGroups: results.groups.map { |
| 20 | 1 | RunTotals.TestGroup(label: $0.label, counts: $0.counts) |
| 21 | 1 | }) |
| 22 | 4 | files = [ |
| 23 | 4 | CoverageSite.File(path: UnavailablePage.sitePath, contents: page.html), |
| 24 | 4 | CoverageSite.File( |
| 25 | 4 | path: RunTotals.fileName, |
| 26 | 4 | contents: String(decoding: try totals.json(), as: UTF8.self)), |
| 27 | 4 | CoverageSite.File(path: SiteStylesheet.fileName, contents: SiteStylesheet.contents), |
| 28 | 4 | CoverageSite.File( |
| 29 | 4 | path: TestsPage.sitePath, |
| 30 | 4 | contents: TestsPage( |
| 31 | 4 | title: title, results: results, |
| 32 | 4 | run: ReportHeader( |
| 33 | 4 | commit: commit, subject: subject, historyPath: links.historyPath) |
| 34 | 4 | ).html), |
| 35 | 4 | ] |
| 36 | 4 | } |
| 37 | | } |