[PATCH 22/22] covoar/Reports: Fix empty branch report

Alex White alexanderjwhite at gmail.com
Mon Mar 1 20:01:29 UTC 2021


This makes the branch report more consistent with the other reports when
there is no branch information found.
---
 tester/covoar/ReportsBase.cc | 12 ++----
 tester/covoar/ReportsHtml.cc | 82 ++++++++++++++++--------------------
 2 files changed, 39 insertions(+), 55 deletions(-)

diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 8252959..3eb546f 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -291,15 +291,9 @@ void ReportsBase::WriteBranchReport(
   if (!report)
     return;
 
-  // If no branches were found of branch coverage is not supported
-  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
-      (BranchInfoAvailable == false) ) {
-
-    PutNoBranchInfo(report);
-
-    // If branches were found, ...
-  } else {
-
+  // If no branches were found then branch coverage is not supported
+  if ((SymbolsToAnalyze->getNumberBranchesFound() != 0) &&
+      (BranchInfoAvailable == true) ) {
     // Process uncovered branches for each symbol.
     count = 0;
     for (ditr = SymbolsToAnalyze->set.begin();
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index 3d20aec..6406a48 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -172,45 +172,43 @@ namespace Coverage {
     // Open the file
     aFile = OpenFile(fileName);
 
-    if ( hasBranches ) {
-      // Put header information into the file
-      fprintf(
-        aFile,
-        "<title>Branch Report</title>\n"
-        "<div class=\"heading-title\">"
-      );
-
-      if (projectName)
-        fprintf(
-          aFile,
-          "%s<br>",
-          projectName
-        );
+    // Put header information into the file
+    fprintf(
+      aFile,
+      "<title>Branch Report</title>\n"
+      "<div class=\"heading-title\">"
+    );
 
+    if (projectName)
       fprintf(
         aFile,
-        "Branch Report</div>\n"
-        "<div class =\"datetime\">%s</div>\n"
-        "<body>\n"
-        "<table class=\"covoar table-autosort:0 table-autofilter table-stripeclass:covoar-tr-odd"
-           TABLE_HEADER_CLASS "\">\n"
-        "<thead>\n"
-        "<tr>\n"
-        "<th class=\"table-sortable:default\" align=\"left\">Symbol</th>\n"
-        "<th class=\"table-sortable:default\" align=\"left\">Line</th>\n"
-        "<th class=\"table-filterable table-sortable:default\" align=\"left\">File</th>\n"
-        "<th class=\"table-sortable:numeric\" align=\"left\">Size <br>Bytes</th>\n"
-        "<th class=\"table-sortable:default\" align=\"left\">Reason</th>\n"
-        "<th class=\"table-filterable table-sortable:default\" align=\"left\">Taken</th>\n"
-	"<th class=\"table-filterable table-sortable:default\" align=\"left\">Not Taken</th>\n"
-        "<th class=\"table-filterable table-sortable:default\" align=\"left\">Classification</th>\n"
-        "<th class=\"table-sortable:default\" align=\"left\">Explanation</th>\n"
-        "</tr>\n"
-        "</thead>\n"
-        "<tbody>\n",
-        asctime( localtime(&timestamp_m) )
+        "%s<br>",
+        projectName
       );
-    }
+
+    fprintf(
+      aFile,
+      "Branch Report</div>\n"
+      "<div class =\"datetime\">%s</div>\n"
+      "<body>\n"
+      "<table class=\"covoar table-autosort:0 table-autofilter table-stripeclass:covoar-tr-odd"
+          TABLE_HEADER_CLASS "\">\n"
+      "<thead>\n"
+      "<tr>\n"
+      "<th class=\"table-sortable:default\" align=\"left\">Symbol</th>\n"
+      "<th class=\"table-sortable:default\" align=\"left\">Line</th>\n"
+      "<th class=\"table-filterable table-sortable:default\" align=\"left\">File</th>\n"
+      "<th class=\"table-sortable:numeric\" align=\"left\">Size <br>Bytes</th>\n"
+      "<th class=\"table-sortable:default\" align=\"left\">Reason</th>\n"
+      "<th class=\"table-filterable table-sortable:default\" align=\"left\">Taken</th>\n"
+      "<th class=\"table-filterable table-sortable:default\" align=\"left\">Not Taken</th>\n"
+      "<th class=\"table-filterable table-sortable:default\" align=\"left\">Classification</th>\n"
+      "<th class=\"table-sortable:default\" align=\"left\">Explanation</th>\n"
+      "</tr>\n"
+      "</thead>\n"
+      "<tbody>\n",
+      asctime( localtime(&timestamp_m) )
+    );
 
     return aFile;
   }
@@ -985,19 +983,11 @@ namespace Coverage {
     bool   hasBranches
   )
   {
-    if ( hasBranches ) {
-      fprintf(
-        aFile,
-        TABLE_FOOTER
-        "</tbody>\n"
-        "</table>\n"
-      );
-    }
     fprintf(
       aFile,
-      "</pre>\n"
-      "</body>\n"
-      "</html>"
+      TABLE_FOOTER
+      "</tbody>\n"
+      "</table>\n"
     );
 
     CloseFile(aFile);
-- 
2.27.0



More information about the devel mailing list