Browse Source

Remove uncovered files from cache coverage data.

Cache coverage data currently contains files with 0 coverage
on each line. This change will remove those files from the coverage
sent to CDash.
Bill Hoffman 13 years ago
parent
commit
0a169e628b
2 changed files with 38 additions and 0 deletions
  1. 36 0
      Source/CTest/cmParseCacheCoverage.cxx
  2. 2 0
      Source/CTest/cmParseCacheCoverage.h

+ 36 - 0
Source/CTest/cmParseCacheCoverage.cxx

@@ -44,9 +44,45 @@ bool cmParseCacheCoverage::LoadCoverageData(const char* d)
         }
         }
       }
       }
     }
     }
+  // now remove files wht no actual coverage...
+  this->RemoveUnCoveredFiles();
   return true;
   return true;
 }
 }
 
 
+void cmParseCacheCoverage::RemoveUnCoveredFiles()
+{
+  // loop over the coverage data computed and remove all files
+  // that only have -1 or 0 for the lines.
+  cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci =
+    this->Coverage.TotalCoverage.begin();
+  while(ci != this->Coverage.TotalCoverage.end())
+    {
+    cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v =
+      ci->second;
+    bool nothing = true;
+    for(cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator i=
+          v.begin(); i != v.end(); ++i)
+      {
+      if(*i > 0)
+        {
+        nothing = false;
+        break;
+        }
+      }
+    if(nothing)
+      {
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                 "No coverage found in: " << ci->first
+                 << std::endl);
+      this->Coverage.TotalCoverage.erase(ci++);
+      }
+    else
+      {
+      ++ci;
+      }
+    }
+}
+
 bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
 bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
                                        std::string const& line)
                                        std::string const& line)
 {
 {

+ 2 - 0
Source/CTest/cmParseCacheCoverage.h

@@ -29,6 +29,8 @@ public:
 protected:
 protected:
   // implement virtual from parent
   // implement virtual from parent
   bool LoadCoverageData(const char* dir);
   bool LoadCoverageData(const char* dir);
+  // remove files with no coverage
+  void RemoveUnCoveredFiles();
   // Read a single mcov file
   // Read a single mcov file
   bool ReadCMCovFile(const char* f);
   bool ReadCMCovFile(const char* f);
   // split a string based on ,
   // split a string based on ,