diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index fb85810089..e4b0a88976 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/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; } +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& args, std::string const& line) { diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h index f377567ccd..114eb92d30 100644 --- a/Source/CTest/cmParseCacheCoverage.h +++ b/Source/CTest/cmParseCacheCoverage.h @@ -29,6 +29,8 @@ public: protected: // implement virtual from parent bool LoadCoverageData(const char* dir); + // remove files with no coverage + void RemoveUnCoveredFiles(); // Read a single mcov file bool ReadCMCovFile(const char* f); // split a string based on ,