Skip to content

Commit 18e1179

Browse files
hanickadotchapuni
authored andcommitted
[llvm-cov] format cells in report with 0/0 branches/functions/lines differenly (gray instead red) and make the table a bit nicer (#75780)
1 parent 5781d79 commit 18e1179

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

llvm/test/tools/llvm-cov/coverage_watermark.test

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,47 @@ INVALID-ARRANGE: error: -coverage-watermark: invalid number range '10,20', must
1313
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -format html -show-region-summary -show-instantiation-summary -o %t.html.dir -path-equivalence=/tmp,%S %S/showTemplateInstantiations.cpp
1414
RUN: FileCheck -check-prefix=ORIGIN %s -input-file %t.html.dir/index.html
1515

16+
ORIGIN: Totals
17+
ORIGIN: <td class='column-entry-green'>
18+
ORIGIN: 100.00% (2/2)
1619
ORIGIN: <td class='column-entry-green'>
1720
ORIGIN: 100.00% (3/3)
1821
ORIGIN: <td class='column-entry-red'>
1922
ORIGIN: 75.00% (9/12)
2023
ORIGIN: <td class='column-entry-red'>
2124
ORIGIN: 66.67% (4/6)
25+
ORIGIN: <td class='column-entry-gray'>
26+
ORIGIN: - (0/0)
27+
ORIGIN: </tr>
2228

23-
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -format html -show-region-summary -show-instantiation-summary -o %t.html.dir -path-equivalence=/tmp,%S -coverage-watermark 80,60 %S/showTemplateInstantiations.cpp
29+
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -format html -show-region-summary -show-instantiation-summary -o %t.html.dir -path-equivalence=/tmp,%S -coverage-watermark 80,70 %S/showTemplateInstantiations.cpp
2430
RUN: FileCheck -check-prefix=DOWNGRADE1 %s -input-file %t.html.dir/index.html
2531

32+
DOWNGRADE:1 Totals
33+
DOWNGRADE1: <td class='column-entry-green'>
34+
DOWNGRADE1: 100.00% (2/2)
2635
DOWNGRADE1: <td class='column-entry-green'>
2736
DOWNGRADE1: 100.00% (3/3)
2837
DOWNGRADE1: <td class='column-entry-yellow'>
2938
DOWNGRADE1: 75.00% (9/12)
3039
DOWNGRADE1: <td class='column-entry-red'>
3140
DOWNGRADE1: 66.67% (4/6)
41+
DOWNGRADE1: <td class='column-entry-gray'>
42+
DOWNGRADE1: - (0/0)
43+
DOWNGRADE1: </tr>
3244

3345
RUN: llvm-cov show %S/Inputs/templateInstantiations.covmapping -instr-profile %S/Inputs/templateInstantiations.profdata -format html -show-region-summary -show-instantiation-summary -o %t.html.dir -path-equivalence=/tmp,%S -coverage-watermark 70,50 %S/showTemplateInstantiations.cpp
3446
RUN: FileCheck -check-prefix=DOWNGRADE2 %s -input-file %t.html.dir/index.html
3547

48+
DOWNGRADE:1 Totals
49+
DOWNGRADE2: <td class='column-entry-green'>
50+
DOWNGRADE2: 100.00% (2/2)
3651
DOWNGRADE2: <td class='column-entry-green'>
3752
DOWNGRADE2: 100.00% (3/3)
3853
DOWNGRADE2: <td class='column-entry-green'>
3954
DOWNGRADE2: 75.00% (9/12)
4055
DOWNGRADE2: <td class='column-entry-yellow'>
4156
DOWNGRADE2: 66.67% (4/6)
57+
DOWNGRADE1: <td class='column-entry-gray'>
58+
DOWNGRADE1: - (0/0)
59+
DOWNGRADE1: </tr>

llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,14 @@ table {
130130
.light-row {
131131
background: #ffffff;
132132
border: 1px solid #dbdbdb;
133+
border-left: none;
134+
border-right: none;
133135
}
134136
.light-row-bold {
135137
background: #ffffff;
136138
border: 1px solid #dbdbdb;
139+
border-left: none;
140+
border-right: none;
137141
font-weight: bold;
138142
}
139143
.column-entry {
@@ -147,21 +151,28 @@ table {
147151
text-align: left;
148152
background-color: #ffffd0;
149153
}
150-
.column-entry-yellow:hover {
154+
.column-entry-yellow:hover, tr:hover .column-entry-yellow {
151155
background-color: #fffff0;
152156
}
153157
.column-entry-red {
154158
text-align: left;
155159
background-color: #ffd0d0;
156160
}
157-
.column-entry-red:hover {
161+
.column-entry-red:hover, tr:hover .column-entry-red {
158162
background-color: #fff0f0;
159163
}
164+
.column-entry-gray {
165+
text-align: left;
166+
background-color: #fbfbfb;
167+
}
168+
.column-entry-gray:hover, tr:hover .column-entry-gray {
169+
background-color: #f0f0f0;
170+
}
160171
.column-entry-green {
161172
text-align: left;
162173
background-color: #d0ffd0;
163174
}
164-
.column-entry-green:hover {
175+
.column-entry-green:hover, tr:hover .column-entry-green {
165176
background-color: #f0fff0;
166177
}
167178
.line-number {
@@ -232,6 +243,9 @@ td:last-child {
232243
tr:hover {
233244
background-color: #f0f0f0;
234245
}
246+
tr:last-child {
247+
border-bottom: none;
248+
}
235249
)";
236250

237251
const char *EndHeader = "</head>";
@@ -309,7 +323,9 @@ void emitTableRow(raw_ostream &OS, const CoverageViewOptions &Opts,
309323
RSO << '(' << Hit << '/' << Total << ')';
310324
}
311325
const char *CellClass = "column-entry-yellow";
312-
if (Pctg >= Opts.HighCovWatermark)
326+
if (!Total)
327+
CellClass = "column-entry-gray";
328+
else if (Pctg >= Opts.HighCovWatermark)
313329
CellClass = "column-entry-green";
314330
else if (Pctg < Opts.LowCovWatermark)
315331
CellClass = "column-entry-red";

0 commit comments

Comments
 (0)