[llvm-cov] Minor visual tweaks for html reports
authorVedant Kumar <vsk@apple.com>
Sat, 10 Sep 2016 19:37:20 +0000 (19:37 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 10 Sep 2016 19:37:20 +0000 (19:37 +0000)
  - Change the location of the 'Region Coverage' column.
  - Use less css and text for some labels.

llvm-svn: 281145

llvm/test/tools/llvm-cov/native_separators.c
llvm/test/tools/llvm-cov/showLineExecutionCounts.cpp
llvm/test/tools/llvm-cov/showProjectSummary.cpp
llvm/test/tools/llvm-cov/style.test
llvm/tools/llvm-cov/SourceCoverageView.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp

index 44813aa..4708738 100644 (file)
 
 // TEXT-INDEX: \tmp\native_separators.c
 // HTML-INDEX: >tmp\native_separators.c</a>
-// HTML: <pre>Source: \tmp\native_separators.c (Binary: native_separators.covmapping)</pre>
+// HTML: <pre>\tmp\native_separators.c (Binary: native_separators.covmapping)</pre>
 
 int main() {}
 
 // RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile=%t.profdata -filename-equivalence %s -o %t.dir
 // RUN: FileCheck -check-prefixes=TEXT -input-file=%t.dir/coverage/tmp/native_separators.c.txt %s
-// TEXT: Source: \tmp\native_separators.c (Binary: native_separators.covmapping)
-
-// Re-purpose this file to test that "Go to first unexecuted line" feature.
-
-// RUN: llvm-cov show %S/Inputs/native_separators.covmapping -instr-profile %t.profdata -filename-equivalence -format html -o %t.dir %s
-// RUN: FileCheck -input-file %t.dir/coverage/tmp/native_separators.c.html %s
-// CHECK-NOT: >Go to first unexecuted line<
+// TEXT: \tmp\native_separators.c (Binary: native_separators.covmapping)
index 8d4397a..fcaedcd 100644 (file)
@@ -78,15 +78,15 @@ int main() {                              // TEXT: [[@LINE]]|   161|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'>Filename</td>
-// HTML-INDEX: <td class='column-entry'>Region Coverage</td>
+// 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: <a href='coverage{{.*}}showLineExecutionCounts.cpp.html'{{.*}}showLineExecutionCounts.cpp</a>
-// HTML-INDEX: <td class='column-entry-red'>
-// HTML-INDEX: 70.00% (7/10)
 // HTML-INDEX: <td class='column-entry-green'>
 // HTML-INDEX: 100.00% (1/1)
 // HTML-INDEX: <td class='column-entry-yellow'>
 // HTML-INDEX: 80.00% (16/20)
+// HTML-INDEX: <td class='column-entry-red'>
+// HTML-INDEX: 70.00% (7/10)
 // HTML-INDEX: TOTALS
index b332914..9939388 100644 (file)
@@ -16,7 +16,7 @@ int main(int argc, char ** argv) {
 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER %s
 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -filename-equivalence %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER %s
 // TEXT-TITLE: Test Suite
-// TEXT: Code Coverage Report
+// TEXT: Coverage Report
 // TEXT: Created:
 // TEXT-FILE: showProjectSummary.cpp:
 // TEXT-FILE: showProjectSummary.covmapping:
@@ -30,13 +30,10 @@ int main(int argc, char ** argv) {
 // RUN: FileCheck -check-prefixes=HTML-TITLE,HTML -input-file %t.dir/index.html %s
 // RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata  -project-title "Test Suite" -filename-equivalence -name=main %s
 // RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER -input-file %t.dir/functions.html %s
-// HTML-TITLE: <div class='project-title'>
-// HTML-TITLE: <span>Test Suite</span>
-// HTML: <div class='report-title'>
-// HTML: <span>Code Coverage Report</span>
-// HTML: <div class='created-time'>
-// HTML: <span>Created:
-// HTML-FILE: <pre>Source: {{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
+// HTML-TITLE: <h1>Test Suite</h1>
+// HTML: <h2>Coverage Report</h2>
+// HTML: <h4>Created:{{.*}}</h4>
+// HTML-FILE: <pre>{{.*}}showProjectSummary.cpp (Binary: showProjectSummary.covmapping)</pre>
 // HTML-FUNCTION: <pre>main</pre>
 // HTML-UNCOVEREDLINE: <a href='#L8'>Go to first unexecuted line</a>
 // HTML-HEADER: <tr><td><span><pre>Line No.</pre></span></td>
index 55ebe85..a37ad85 100644 (file)
@@ -17,6 +17,7 @@ STYLE-DAG: .expansion-view
 STYLE-DAG: .line-number
 STYLE-DAG: .light-row
 STYLE-DAG: .column-entry
+STYLE-DAG: .column-entry-left
 STYLE-DAG: .column-entry-yellow
 STYLE-DAG: .column-entry-red
 STYLE-DAG: .column-entry-green
index b27782b..23c86e3 100644 (file)
@@ -150,7 +150,7 @@ std::string SourceCoverageView::getSourceName() const {
 }
 
 std::string SourceCoverageView::getVerboseSourceName() const {
-  return "Source: " + getSourceName() + " (Binary: " +
+  return getSourceName() + " (Binary: " +
          sys::path::filename(getOptions().ObjectFilename).str() + ")";
 }
 
@@ -169,7 +169,7 @@ void SourceCoverageView::addInstantiation(
 void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
                                bool ShowSourceName, unsigned ViewDepth) {
   if (WholeFile)
-    renderCellInTitle(OS, "Code Coverage Report");
+    renderCellInTitle(OS, "Coverage Report");
 
   renderViewHeader(OS);
 
index d05bbdc..8bb5159 100644 (file)
@@ -119,6 +119,9 @@ table {
 .column-entry {
   text-align: right;
 }
+.column-entry-left {
+  text-align: left;
+}
 .column-entry-yellow {
   text-align: right;
   background-color: #ffffd0;
@@ -192,23 +195,6 @@ td:first-child {
 td:last-child {
   border-right: none;
 }
-.project-title {
-  font-size:36.0pt;
-  line-height:200%;
-  font-family:Calibri;
-  font-weight: bold;
-}
-.report-title {
-  font-size:16.0pt;
-  line-height:120%;
-  font-family:Arial;
-  font-weight: bold;
-}
-.created-time {
-  font-size:14.0pt;
-  line-height:120%;
-  font-family:Arial;
-}
 )";
 
 const char *EndHeader = "</head>";
@@ -237,19 +223,11 @@ const char *BeginTable = "<table>";
 
 const char *EndTable = "</table>";
 
-const char *BeginProjectTitleDiv = "<div class='project-title'>";
-
-const char *EndProjectTitleDiv = "</div>";
-
-const char *BeginReportTitleDiv = "<div class='report-title'>";
-
-const char *EndReportTitleDiv = "</div>";
-
-const char *BeginCreatedTimeDiv = "<div class='created-time'>";
+const char *ProjectTitleTag = "h1";
 
-const char *EndCreatedTimeDiv = "</div>";
+const char *ReportTitleTag = "h2";
 
-const char *LineBreak = "<br>";
+const char *CreatedTimeTag = "h4";
 
 std::string getPathToStyle(StringRef ViewPath) {
   std::string PathToStyle = "";
@@ -308,8 +286,9 @@ void CoveragePrinterHTML::closeViewFile(OwnedStream OS) {
 /// Emit column labels for the table in the index.
 static void emitColumnLabelsForIndex(raw_ostream &OS) {
   SmallVector<std::string, 4> Columns;
+  Columns.emplace_back(tag("td", "Filename", "column-entry-left"));
   for (const char *Label :
-       {"Filename", "Region Coverage", "Function Coverage", "Line Coverage"})
+       {"Function Coverage", "Line Coverage", "Region Coverage"})
     Columns.emplace_back(tag("td", Label, "column-entry"));
   OS << tag("tr", join(Columns.begin(), Columns.end(), ""));
 }
@@ -334,7 +313,7 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF,
       CellClass = "column-entry-red";
     else if (Hit == Total)
       CellClass = "column-entry-green";
-    Columns.emplace_back(tag("td", tag("pre", S, "code"), CellClass));
+    Columns.emplace_back(tag("td", tag("pre", S), CellClass));
   };
 
   // Simplify the display file path, and wrap it in a link if requested.
@@ -351,16 +330,16 @@ void CoveragePrinterHTML::emitFileSummary(raw_ostream &OS, StringRef SF,
     Filename = a(LinkTarget, LinkText);
   }
 
-  Columns.emplace_back(tag("td", tag("pre", Filename, "code")));
-  AddCoverageTripleToColumn(
-      FCS.RegionCoverage.NumRegions - FCS.RegionCoverage.NotCovered,
-      FCS.RegionCoverage.NumRegions, FCS.RegionCoverage.getPercentCovered());
+  Columns.emplace_back(tag("td", tag("pre", Filename)));
   AddCoverageTripleToColumn(FCS.FunctionCoverage.Executed,
                             FCS.FunctionCoverage.NumFunctions,
                             FCS.FunctionCoverage.getPercentCovered());
   AddCoverageTripleToColumn(
       FCS.LineCoverage.NumLines - FCS.LineCoverage.NotCovered,
       FCS.LineCoverage.NumLines, FCS.LineCoverage.getPercentCovered());
+  AddCoverageTripleToColumn(
+      FCS.RegionCoverage.NumRegions - FCS.RegionCoverage.NotCovered,
+      FCS.RegionCoverage.NumRegions, FCS.RegionCoverage.getPercentCovered());
 
   OS << tag("tr", join(Columns.begin(), Columns.end(), ""), "light-row");
 }
@@ -388,16 +367,10 @@ Error CoveragePrinterHTML::createIndexFile(
 
   // Emit some basic information about the coverage report.
   if (Opts.hasProjectTitle())
-    OSRef << BeginProjectTitleDiv
-          << tag("span", escape(Opts.ProjectTitle, Opts)) << EndProjectTitleDiv;
-  OSRef << BeginReportTitleDiv
-        << tag("span", escape("Code Coverage Report", Opts))
-        << EndReportTitleDiv;
+    OSRef << tag(ProjectTitleTag, escape(Opts.ProjectTitle, Opts));
+  OSRef << tag(ReportTitleTag, "Coverage Report");
   if (Opts.hasCreatedTime())
-    OSRef << BeginCreatedTimeDiv
-          << tag("span", escape(Opts.CreatedTimeStr, Opts))
-          << EndCreatedTimeDiv;
-  OSRef << LineBreak;
+    OSRef << tag(CreatedTimeTag, escape(Opts.CreatedTimeStr, Opts));
 
   // Emit a table containing links to reports for each file in the covmapping.
   CoverageReport Report(Opts, Coverage);
@@ -415,7 +388,7 @@ Error CoveragePrinterHTML::createIndexFile(
 }
 
 void SourceCoverageViewHTML::renderViewHeader(raw_ostream &OS) {
-  OS << LineBreak << BeginCenteredDiv << BeginTable;
+  OS << BeginCenteredDiv << BeginTable;
 }
 
 void SourceCoverageViewHTML::renderViewFooter(raw_ostream &OS) {
@@ -627,17 +600,11 @@ void SourceCoverageViewHTML::renderInstantiationView(raw_ostream &OS,
 void SourceCoverageViewHTML::renderCellInTitle(raw_ostream &OS,
                                                StringRef CellText) {
   if (getOptions().hasProjectTitle())
-    OS << BeginProjectTitleDiv
-       << tag("span", escape(getOptions().ProjectTitle, getOptions()))
-       << EndProjectTitleDiv;
-
-  OS << BeginReportTitleDiv << tag("span", escape(CellText, getOptions()))
-     << EndReportTitleDiv;
-
+    OS << tag(ProjectTitleTag, escape(getOptions().ProjectTitle, getOptions()));
+  OS << tag(ReportTitleTag, escape(CellText, getOptions()));
   if (getOptions().hasCreatedTime())
-    OS << BeginCreatedTimeDiv
-       << tag("span", escape(getOptions().CreatedTimeStr, getOptions()))
-       << EndCreatedTimeDiv;
+    OS << tag(CreatedTimeTag,
+              escape(getOptions().CreatedTimeStr, getOptions()));
 }
 
 void SourceCoverageViewHTML::renderTableHeader(raw_ostream &OS,