1import 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.
5public 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
124 ) throws {
134 let page = UnavailablePage(
144 title: title, reason: reason, commit: commit, subject: subject, links: links)
154 let results = results ?? TestResults(merging: [])
164 let totals = RunTotals(
174 commit: commit, subject: subject, date: date, tests: results.counts, files: [],
184 unavailable: reason, hasTestsPage: true,
194 testGroups: results.groups.map {
201 RunTotals.TestGroup(label: $0.label, counts: $0.counts)
211 })
224 files = [
234 CoverageSite.File(path: UnavailablePage.sitePath, contents: page.html),
244 CoverageSite.File(
254 path: RunTotals.fileName,
264 contents: String(decoding: try totals.json(), as: UTF8.self)),
274 CoverageSite.File(path: SiteStylesheet.fileName, contents: SiteStylesheet.contents),
284 CoverageSite.File(
294 path: TestsPage.sitePath,
304 contents: TestsPage(
314 title: title, results: results,
324 run: ReportHeader(
334 commit: commit, subject: subject, historyPath: links.historyPath)
344 ).html),
354 ]
364 }
37}