ENH: Some more cleanups and add ctest custom vector for regular expression to exclude from coverage

This commit is contained in:
Andy Cedilnik 2005-07-14 14:15:51 -04:00
parent 79eeb9c4e6
commit 0d14b57605

View File

@ -252,7 +252,7 @@ int cmCTestCoverageHandler::ProcessHandler()
std::set<std::string> missingFiles; std::set<std::string> missingFiles;
std::string actualSourceFile = ""; std::string actualSourceFile = "";
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Performing coverage (each . represents one file):" << std::endl); cmCTestLog(m_CTest, HANDLER_OUTPUT, " Processing coverage (each . represents one file):" << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " "); cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
int file_count = 0; int file_count = 0;
for ( it = files.begin(); it != files.end(); ++ it ) for ( it = files.begin(); it != files.end(); ++ it )
@ -558,13 +558,27 @@ int cmCTestCoverageHandler::ProcessHandler()
long total_untested = 0; long total_untested = 0;
//std::string fullSourceDir = sourceDir + "/"; //std::string fullSourceDir = sourceDir + "/";
//std::string fullBinaryDir = binaryDir + "/"; //std::string fullBinaryDir = binaryDir + "/";
cmCTestLog(m_CTest, HANDLER_OUTPUT, std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Acumulating results (each . represents one file):" << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
std::vector<std::string> errorsWhileAccumulating;
file_count = 0;
for ( fileIterator = totalCoverage.begin(); for ( fileIterator = totalCoverage.begin();
fileIterator != totalCoverage.end(); fileIterator != totalCoverage.end();
++fileIterator ) ++fileIterator )
{ {
if ( cnt == 100 ) cmCTestLog(m_CTest, HANDLER_OUTPUT, "." << std::flush);
file_count ++;
if ( file_count % 50 == 0 )
{
cmCTestLog(m_CTest, HANDLER_OUTPUT, " processed: " << file_count << " out of "
<< totalCoverage.size() << std::endl);
cmCTestLog(m_CTest, HANDLER_OUTPUT, " ");
}
if ( cnt % 100 == 0 )
{ {
cnt = 0;
this->EndCoverageLogFile(covLogFile, logFileCount); this->EndCoverageLogFile(covLogFile, logFileCount);
logFileCount ++; logFileCount ++;
if ( !this->StartCoverageLogFile(covLogFile, logFileCount) ) if ( !this->StartCoverageLogFile(covLogFile, logFileCount) )
@ -575,7 +589,7 @@ int cmCTestCoverageHandler::ProcessHandler()
const std::string fullFileName = fileIterator->first; const std::string fullFileName = fileIterator->first;
const std::string fileName = cmSystemTools::GetFilenameName(fullFileName.c_str()); const std::string fileName = cmSystemTools::GetFilenameName(fullFileName.c_str());
std::string fullFilePath = cmSystemTools::GetFilenamePath(fullFileName.c_str()); std::string fullFilePath = cmSystemTools::GetFilenamePath(fullFileName.c_str());
cmCTestLog(m_CTest, ERROR_MESSAGE, "Process file: " << fullFileName << std::endl); cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, "Process file: " << fullFileName << std::endl);
cmSystemTools::ConvertToUnixSlashes(fullFilePath); cmSystemTools::ConvertToUnixSlashes(fullFilePath);
@ -590,7 +604,7 @@ int cmCTestCoverageHandler::ProcessHandler()
sourceDir.c_str(), binaryDir.c_str()); sourceDir.c_str(), binaryDir.c_str());
if ( !shouldIDoCoverage ) if ( !shouldIDoCoverage )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, ".NoDartCoverage found, so skip coverage check for: " cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, ".NoDartCoverage found, so skip coverage check for: "
<< fullFileName.c_str() << fullFileName.c_str()
<< std::endl); << std::endl);
continue; continue;
@ -606,7 +620,9 @@ int cmCTestCoverageHandler::ProcessHandler()
std::ifstream ifs(fullFileName.c_str()); std::ifstream ifs(fullFileName.c_str());
if ( !ifs) if ( !ifs)
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot open source file: " << fullFileName.c_str() << std::endl); cmOStringStream ostr;
ostr << "Cannot open source file: " << fullFileName.c_str();
errorsWhileAccumulating.push_back(ostr.str());
error ++; error ++;
continue; continue;
} }
@ -620,7 +636,9 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
if ( !cmSystemTools::GetLineFromStream(ifs, line) ) if ( !cmSystemTools::GetLineFromStream(ifs, line) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem reading source file: " << fullFileName.c_str() << " line:" << cc << std::endl); cmOStringStream ostr;
ostr << "Problem reading source file: " << fullFileName.c_str() << " line:" << cc;
errorsWhileAccumulating.push_back(ostr.str());
error ++; error ++;
break; break;
} }
@ -637,7 +655,9 @@ int cmCTestCoverageHandler::ProcessHandler()
} }
if ( cmSystemTools::GetLineFromStream(ifs, line) ) if ( cmSystemTools::GetLineFromStream(ifs, line) )
{ {
cmCTestLog(m_CTest, ERROR_MESSAGE, "Looks like there are more lines in the file: " << line << std::endl); cmOStringStream ostr;
ostr << "Looks like there are more lines in the file: " << line;
errorsWhileAccumulating.push_back(ostr.str());
} }
float cper = 0; float cper = 0;
float cmet = 0; float cmet = 0;
@ -671,6 +691,19 @@ int cmCTestCoverageHandler::ProcessHandler()
} }
this->EndCoverageLogFile(covLogFile, logFileCount); this->EndCoverageLogFile(covLogFile, logFileCount);
if ( errorsWhileAccumulating.size() > 0 )
{
cmCTestLog(m_CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(m_CTest, ERROR_MESSAGE, "Error(s) while acumulating results:" << std::endl);
std::vector<std::string>::iterator erIt;
for ( erIt = errorsWhileAccumulating.begin();
erIt != errorsWhileAccumulating.end();
++ erIt )
{
cmCTestLog(m_CTest, ERROR_MESSAGE, " " << erIt->c_str() << std::endl);
}
}
int total_lines = total_tested + total_untested; int total_lines = total_tested + total_untested;
float percent_coverage = 100 * SAFEDIV(static_cast<float>(total_tested), float percent_coverage = 100 * SAFEDIV(static_cast<float>(total_tested),
static_cast<float>(total_lines)); static_cast<float>(total_lines));
@ -723,6 +756,14 @@ int cmCTestCoverageHandler::ProcessHandler()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
{ {
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude regular expressions." << std::endl);
cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE", cmCTest::PopulateCustomVector(mf, "CTEST_CUSTOM_COVERAGE_EXCLUDE",
m_CustomCoverageExclude); m_CustomCoverageExclude);
std::vector<cmStdString>::iterator it;
for ( it = m_CustomCoverageExclude.begin();
it != m_CustomCoverageExclude.end();
++ it )
{
cmCTestLog(m_CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: " << it->c_str() << std::endl);
}
} }