[llvm] r323892 - [llvm-cov] Improvements for summary report generated in HTML format.

Max Moroz via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 31 09:37:21 PST 2018


Author: dor1s
Date: Wed Jan 31 09:37:21 2018
New Revision: 323892

URL: http://llvm.org/viewvc/llvm-project?rev=323892&view=rev
Log:
[llvm-cov] Improvements for summary report generated in HTML format.

Summary:
This commit adds the following changes:

1) coverage numbers are aligned to the left and padded with spaces in order to
provide better readability for percentage values, e.g.:

```
file1     |  89.13% (123 / 2323)    | 100.00% (55 / 55)    |   9.33% (14545 / 234234)
file_asda |   1.78% ( 23 / 4323)    |  32.31% (555 / 6555) |  67.89% (1545 / 2234)
fileXXX   | 100.00% (12323 / 12323) | 100.00% (555 / 555)  | 100.00% (12345 / 12345)
```

2) added "hover" attribute to CSS for highlighting table row under mouse cursor
see screenshot attached to the phabricator review page

{F5764813}

3) table title row and "totals" row now use bold text

Reviewers: vsk, morehouse

Reviewed By: vsk

Subscribers: kcc, llvm-commits

Differential Revision: https://reviews.llvm.org/D42093

Modified:
    llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test
    llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
    llvm/trunk/test/tools/llvm-cov/style.test
    llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp

Modified: llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test?rev=323892&r1=323891&r2=323892&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test (original)
+++ llvm/trunk/test/tools/llvm-cov/hideUnexecutedSubviews.test Wed Jan 31 09:37:21 2018
@@ -11,11 +11,11 @@ FILE-NOT: Unexecuted instantiation
 
 RUN: FileCheck -check-prefix=INDEX %s -input-file %t.html.dir/index.html
 
-INDEX: <td class='column-entry-left'>Filename</td>
-INDEX: <td class='column-entry'>Function Coverage</td>
-INDEX: <td class='column-entry'>Instantiation Coverage</td>
-INDEX: <td class='column-entry'>Line Coverage</td>
-INDEX: <td class='column-entry'>Region Coverage</td>
+INDEX: <td class='column-entry-bold'>Filename</td>
+INDEX: <td class='column-entry-bold'>Function Coverage</td>
+INDEX: <td class='column-entry-bold'>Instantiation Coverage</td>
+INDEX: <td class='column-entry-bold'>Line Coverage</td>
+INDEX: <td class='column-entry-bold'>Region Coverage</td>
 INDEX: <td class='column-entry-red'>
 INDEX: 50.00% (1/2)
 INDEX: <td class='column-entry-red'>

Modified: llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp?rev=323892&r1=323891&r2=323892&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/showLineExecutionCounts.cpp Wed Jan 31 09:37:21 2018
@@ -62,10 +62,10 @@ int main() {
 //
 // RUN: FileCheck -check-prefix HTML-INDEX -input-file %t.html.dir/index.html %s
 // HTML-INDEX-LABEL: <table>
-// HTML-INDEX: <td class='column-entry-left'>Filename</td>
-// HTML-INDEX: <td class='column-entry'>Function Coverage</td>
-// HTML-INDEX: <td class='column-entry'>Line Coverage</td>
-// HTML-INDEX: <td class='column-entry'>Region Coverage</td>
+// HTML-INDEX: <td class='column-entry-bold'>Filename</td>
+// HTML-INDEX: <td class='column-entry-bold'>Function Coverage</td>
+// HTML-INDEX: <td class='column-entry-bold'>Line Coverage</td>
+// HTML-INDEX: <td class='column-entry-bold'>Region Coverage</td>
 // HTML-INDEX: <a href='coverage{{.*}}showLineExecutionCounts.cpp.html'{{.*}}showLineExecutionCounts.cpp</a>
 // HTML-INDEX: <td class='column-entry-green'>
 // HTML-INDEX: 100.00% (1/1)
@@ -73,4 +73,5 @@ int main() {
 // HTML-INDEX: 90.00% (18/20)
 // HTML-INDEX: <td class='column-entry-red'>
 // HTML-INDEX: 72.73% (8/11)
-// HTML-INDEX: TOTALS
+// HTML-INDEX: <tr class='light-row-bold'>
+// HTML-INDEX: Totals

Modified: llvm/trunk/test/tools/llvm-cov/style.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/style.test?rev=323892&r1=323891&r2=323892&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/style.test (original)
+++ llvm/trunk/test/tools/llvm-cov/style.test Wed Jan 31 09:37:21 2018
@@ -19,15 +19,23 @@ STYLE-DAG: .centered
 STYLE-DAG: .expansion-view
 STYLE-DAG: .line-number
 STYLE-DAG: .light-row
+STYLE-DAG: .light-row-bold
 STYLE-DAG: .column-entry
-STYLE-DAG: .column-entry-left
+STYLE-DAG: .column-entry-bold
 STYLE-DAG: .column-entry-yellow
+STYLE-DAG: .column-entry-yellow:hover
 STYLE-DAG: .column-entry-red
+STYLE-DAG: .column-entry-red:hover
 STYLE-DAG: .column-entry-green
+STYLE-DAG: .column-entry-green:hover
 STYLE-DAG: .covered-line
 STYLE-DAG: .uncovered-line
 STYLE-DAG: .tooltip
 STYLE-DAG: .tooltip span.tooltip-content
+STYLE-DAG: th, td
+STYLE-DAG: td:first-child
+STYLE-DAG: td:last-child
+STYLE-DAG: tr:hover
 
 TOPLEVEL-NOT: <style>
 TOPLEVEL: <head>

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp?rev=323892&r1=323891&r2=323892&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageViewHTML.cpp Wed Jan 31 09:37:21 2018
@@ -116,24 +116,39 @@ table {
   background: #ffffff;
   border: 1px solid #dbdbdb;
 }
+.light-row-bold {
+  background: #ffffff;
+  border: 1px solid #dbdbdb;
+  font-weight: bold;
+}
 .column-entry {
-  text-align: right;
+  text-align: left;
 }
-.column-entry-left {
+.column-entry-bold {
+  font-weight: bold;
   text-align: left;
 }
 .column-entry-yellow {
-  text-align: right;
+  text-align: left;
   background-color: #ffffd0;
 }
+.column-entry-yellow:hover {
+  background-color: #fffff0;
+}
 .column-entry-red {
-  text-align: right;
+  text-align: left;
   background-color: #ffd0d0;
 }
+.column-entry-red:hover {
+  background-color: #fff0f0;
+}
 .column-entry-green {
-  text-align: right;
+  text-align: left;
   background-color: #d0ffd0;
 }
+.column-entry-green:hover {
+  background-color: #f0fff0;
+}
 .line-number {
   text-align: right;
   color: #aaa;
@@ -184,10 +199,11 @@ table {
 }
 th, td {
   vertical-align: top;
-  padding: 2px 5px;
+  padding: 2px 8px;
   border-collapse: collapse;
   border-right: solid 1px #eee;
   border-left: solid 1px #eee;
+  text-align: left;
 }
 td:first-child {
   border-left: none;
@@ -195,6 +211,9 @@ td:first-child {
 td:last-child {
   border-right: none;
 }
+tr:hover {
+  background-color: #f0f0f0;
+}
 )";
 
 const char *EndHeader = "</head>";
@@ -287,13 +306,14 @@ void CoveragePrinterHTML::closeViewFile(
 static void emitColumnLabelsForIndex(raw_ostream &OS,
                                      const CoverageViewOptions &Opts) {
   SmallVector<std::string, 4> Columns;
-  Columns.emplace_back(tag("td", "Filename", "column-entry-left"));
-  Columns.emplace_back(tag("td", "Function Coverage", "column-entry"));
+  Columns.emplace_back(tag("td", "Filename", "column-entry-bold"));
+  Columns.emplace_back(tag("td", "Function Coverage", "column-entry-bold"));
   if (Opts.ShowInstantiationSummary)
-    Columns.emplace_back(tag("td", "Instantiation Coverage", "column-entry"));
-  Columns.emplace_back(tag("td", "Line Coverage", "column-entry"));
+    Columns.emplace_back(
+        tag("td", "Instantiation Coverage", "column-entry-bold"));
+  Columns.emplace_back(tag("td", "Line Coverage", "column-entry-bold"));
   if (Opts.ShowRegionSummary)
-    Columns.emplace_back(tag("td", "Region Coverage", "column-entry"));
+    Columns.emplace_back(tag("td", "Region Coverage", "column-entry-bold"));
   OS << tag("tr", join(Columns.begin(), Columns.end(), ""));
 }
 
@@ -323,7 +343,7 @@ void CoveragePrinterHTML::emitFileSummar
     {
       raw_string_ostream RSO{S};
       if (Total)
-        RSO << format("%*.2f", 7, Pctg) << "% ";
+        RSO << format("%6.2f", 7, Pctg) << "% ";
       else
         RSO << "- ";
       RSO << '(' << Hit << '/' << Total << ')';
@@ -339,7 +359,7 @@ void CoveragePrinterHTML::emitFileSummar
   // Simplify the display file path, and wrap it in a link if requested.
   std::string Filename;
   if (IsTotals) {
-    Filename = "TOTALS";
+    Filename = SF;
   } else {
     Filename = buildLinkToFile(SF, FCS);
   }
@@ -360,7 +380,10 @@ void CoveragePrinterHTML::emitFileSummar
                               FCS.RegionCoverage.getNumRegions(),
                               FCS.RegionCoverage.getPercentCovered());
 
-  OS << tag("tr", join(Columns.begin(), Columns.end(), ""), "light-row");
+  if (IsTotals)
+    OS << tag("tr", join(Columns.begin(), Columns.end(), ""), "light-row-bold");
+  else
+    OS << tag("tr", join(Columns.begin(), Columns.end(), ""), "light-row");
 }
 
 Error CoveragePrinterHTML::createIndexFile(




More information about the llvm-commits mailing list