[llvm] 18e1179 - [llvm-cov] format cells in report with 0/0 branches/functions/lines differenly (gray instead red) and make the table a bit nicer (#75780)
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 02:15:57 PST 2023
Author: Hana Dusíková
Date: 2023-12-19T19:15:39+09:00
New Revision: 18e1179208a1bcf561c76cd50460e1a411171736
URL: https://github.com/llvm/llvm-project/commit/18e1179208a1bcf561c76cd50460e1a411171736
DIFF: https://github.com/llvm/llvm-project/commit/18e1179208a1bcf561c76cd50460e1a411171736.diff
LOG: [llvm-cov] format cells in report with 0/0 branches/functions/lines differenly (gray instead red) and make the table a bit nicer (#75780)
Added:
Modified:
llvm/test/tools/llvm-cov/coverage_watermark.test
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-cov/coverage_watermark.test b/llvm/test/tools/llvm-cov/coverage_watermark.test
index 1c0408dd0078c9..5c48b4f0fb4bf4 100644
--- a/llvm/test/tools/llvm-cov/coverage_watermark.test
+++ b/llvm/test/tools/llvm-cov/coverage_watermark.test
@@ -13,29 +13,47 @@ INVALID-ARRANGE: error: -coverage-watermark: invalid number range '10,20', must
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
RUN: FileCheck -check-prefix=ORIGIN %s -input-file %t.html.dir/index.html
+ORIGIN: Totals
+ORIGIN: <td class='column-entry-green'>
+ORIGIN: 100.00% (2/2)
ORIGIN: <td class='column-entry-green'>
ORIGIN: 100.00% (3/3)
ORIGIN: <td class='column-entry-red'>
ORIGIN: 75.00% (9/12)
ORIGIN: <td class='column-entry-red'>
ORIGIN: 66.67% (4/6)
+ORIGIN: <td class='column-entry-gray'>
+ORIGIN: - (0/0)
+ORIGIN: </tr>
-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
+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
RUN: FileCheck -check-prefix=DOWNGRADE1 %s -input-file %t.html.dir/index.html
+DOWNGRADE:1 Totals
+DOWNGRADE1: <td class='column-entry-green'>
+DOWNGRADE1: 100.00% (2/2)
DOWNGRADE1: <td class='column-entry-green'>
DOWNGRADE1: 100.00% (3/3)
DOWNGRADE1: <td class='column-entry-yellow'>
DOWNGRADE1: 75.00% (9/12)
DOWNGRADE1: <td class='column-entry-red'>
DOWNGRADE1: 66.67% (4/6)
+DOWNGRADE1: <td class='column-entry-gray'>
+DOWNGRADE1: - (0/0)
+DOWNGRADE1: </tr>
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
RUN: FileCheck -check-prefix=DOWNGRADE2 %s -input-file %t.html.dir/index.html
+DOWNGRADE:1 Totals
+DOWNGRADE2: <td class='column-entry-green'>
+DOWNGRADE2: 100.00% (2/2)
DOWNGRADE2: <td class='column-entry-green'>
DOWNGRADE2: 100.00% (3/3)
DOWNGRADE2: <td class='column-entry-green'>
DOWNGRADE2: 75.00% (9/12)
DOWNGRADE2: <td class='column-entry-yellow'>
DOWNGRADE2: 66.67% (4/6)
+DOWNGRADE1: <td class='column-entry-gray'>
+DOWNGRADE1: - (0/0)
+DOWNGRADE1: </tr>
diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index b43e9e64231e0c..abc4c49ecae98e 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -130,10 +130,14 @@ table {
.light-row {
background: #ffffff;
border: 1px solid #dbdbdb;
+ border-left: none;
+ border-right: none;
}
.light-row-bold {
background: #ffffff;
border: 1px solid #dbdbdb;
+ border-left: none;
+ border-right: none;
font-weight: bold;
}
.column-entry {
@@ -147,21 +151,28 @@ table {
text-align: left;
background-color: #ffffd0;
}
-.column-entry-yellow:hover {
+.column-entry-yellow:hover, tr:hover .column-entry-yellow {
background-color: #fffff0;
}
.column-entry-red {
text-align: left;
background-color: #ffd0d0;
}
-.column-entry-red:hover {
+.column-entry-red:hover, tr:hover .column-entry-red {
background-color: #fff0f0;
}
+.column-entry-gray {
+ text-align: left;
+ background-color: #fbfbfb;
+}
+.column-entry-gray:hover, tr:hover .column-entry-gray {
+ background-color: #f0f0f0;
+}
.column-entry-green {
text-align: left;
background-color: #d0ffd0;
}
-.column-entry-green:hover {
+.column-entry-green:hover, tr:hover .column-entry-green {
background-color: #f0fff0;
}
.line-number {
@@ -232,6 +243,9 @@ td:last-child {
tr:hover {
background-color: #f0f0f0;
}
+tr:last-child {
+ border-bottom: none;
+}
)";
const char *EndHeader = "</head>";
@@ -309,7 +323,9 @@ void emitTableRow(raw_ostream &OS, const CoverageViewOptions &Opts,
RSO << '(' << Hit << '/' << Total << ')';
}
const char *CellClass = "column-entry-yellow";
- if (Pctg >= Opts.HighCovWatermark)
+ if (!Total)
+ CellClass = "column-entry-gray";
+ else if (Pctg >= Opts.HighCovWatermark)
CellClass = "column-entry-green";
else if (Pctg < Opts.LowCovWatermark)
CellClass = "column-entry-red";
More information about the llvm-commits
mailing list