From 589b4265a60f1d9778cf37e4e87a0fcb399e48d8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 11 Mar 2009 13:31:40 -0400 Subject: [PATCH] BUG: Do not produce empty coverage log files This moves the filtering of source files to before the production of coverage log files in order to avoid producing a CoverageLog-*.xml file for 100 filtered-out files. The change greatly reduces the number of submitted coverage files when using label filters. --- Source/CTest/cmCTestCoverageHandler.cxx | 45 +++++++++++++------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 59c91ecb8..cd0468022 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -464,28 +464,8 @@ int cmCTestCoverageHandler::ProcessHandler() << cont.TotalCoverage.size() << std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); } - if ( cnt % 100 == 0 ) - { - this->EndCoverageLogFile(covLogFile, logFileCount); - logFileCount ++; - if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) - { - return -1; - } - } + const std::string fullFileName = fileIterator->first; - const std::string fileName - = cmSystemTools::GetFilenameName(fullFileName.c_str()); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Process file: " << fullFileName << std::endl); - - if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " - << fullFileName.c_str() << std::endl); - continue; - } - bool shouldIDoCoverage = this->ShouldIDoCoverage(fullFileName.c_str(), sourceDir.c_str(), binaryDir.c_str()); @@ -498,6 +478,28 @@ int cmCTestCoverageHandler::ProcessHandler() continue; } + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Process file: " << fullFileName << std::endl); + + if ( !cmSystemTools::FileExists(fullFileName.c_str()) ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: " + << fullFileName.c_str() << std::endl); + continue; + } + + if ( ++cnt % 100 == 0 ) + { + this->EndCoverageLogFile(covLogFile, logFileCount); + logFileCount ++; + if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) + { + return -1; + } + } + + const std::string fileName + = cmSystemTools::GetFilenameName(fullFileName.c_str()); std::string shortFileName = this->CTest->GetShortPathToFile(fullFileName.c_str()); const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov @@ -582,7 +584,6 @@ int cmCTestCoverageHandler::ProcessHandler() covSumFile << (cmet) << "\n"; this->WriteXMLLabels(covSumFile, shortFileName); covSumFile << "\t" << std::endl; - cnt ++; } this->EndCoverageLogFile(covLogFile, logFileCount);