Atlas › Test

TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetail

Exact test identity: go.temporal.io/server/tools/testrunner/TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetail

Package
go.temporal.io/server/tools/testrunner
Suite / test hierarchy
TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetail
Test
TestRenderSummaryFromReports_Markdown_ShowsTruncatedDetail
Introduced at
summary.go ×1 Frontier kind: Joint frontier
Covered ranges
12
Covered lines
44
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/testrunner/summary.go 44 covered LOC · 12 ranges

Open complete file

25 // Markdown renders the GitHub step summary HTML and enforces both the total
26 // summary budget and per-row detail truncation.
27 > func (s summary) Markdown() string { summary.go
28 > if len(s.Rows) == 0 {
29 return ""
30 }
31
32 > var sb strings.Builder summary.go
33 > sb.WriteString("<table>\n<tr><th>Kind</th><th>Test</th></tr>\n")
34 >
35 > // Reserve bytes for the closing tag so we can always finish the table.
36 > const tableClose = "</table>\n"
37 > budget := summaryMarkdownMaxBytes - sb.Len() - len(tableClose)
38 >
39 > written := 0
40 > for _, row := range s.Rows {
41 > rendered := row.Markdown()
42 > if len(rendered) > budget {
43 omitted := len(s.Rows) - written
44 fmt.Fprintf(&sb, "<tr><td colspan=\"2\">… %d failure(s) not shown — see full output in job logs</td></tr>\n", omitted)
45 break
46 }
47 > sb.WriteString(rendered) summary.go
48 > budget -= len(rendered)
49 > written++
50 }
51
52 > sb.WriteString(tableClose) summary.go
53 > return sb.String()
54 }
55
90 }
91
92 > func newSummaryRow(kind failureType, name string, details string) summaryRow { summary.go
93 > if len(details) > summaryMaxDetailBytes {
94 > headBytes := (summaryMaxDetailBytes - len(summaryTruncatedMarker)) / 2 summary.go
95 > tailBytes := summaryMaxDetailBytes - len(summaryTruncatedMarker) - headBytes
96 > details = details[:headBytes] + summaryTruncatedMarker + details[len(details)-tailBytes:]
97 > }
98 > return summaryRow{ summary.go
99 > Kind: kind,
100 > Name: name,
101 > Details: details,
102 > Final: strings.Contains(name, "(final)"),
103 > }
104 }
105
106 // Markdown renders one summary table row.
107 > func (row summaryRow) Markdown() string { summary.go
108 > kind := string(row.Kind)
109 > if row.Final {
110 kind = "❌ " + kind
111 }
112
113 > var sb strings.Builder summary.go
114 > fmt.Fprintf(&sb, "<tr><td>%s</td><td>", html.EscapeString(kind))
115 > if row.Details != "" {
116 > escaped := html.EscapeString(row.Details)
117 > if strings.Contains(row.Details, summaryTruncatedMarker) {
118 > escaped += "\n… (truncated — see full output in job logs)" summary.go
119 > }
120 > fmt.Fprintf(&sb, "<details><summary>%s</summary><pre>%s</pre></details>", summary.go
121 > html.EscapeString(row.Name), escaped)
122 } else {
123 sb.WriteString(html.EscapeString(row.Name))
124 }
125 > sb.WriteString("</td></tr>\n") summary.go
126 > return sb.String()
127 }