Change coverage globbing mechanism to resolve paths earlier

This commit is contained in:
Zach Mullen 2010-05-07 11:00:21 -04:00
parent 678073bec2
commit 231cbbef80

View File

@ -583,17 +583,17 @@ int cmCTestCoverageHandler::ProcessHandler()
i != uncovered.end(); ++i) i != uncovered.end(); ++i)
{ {
std::string fileName = cmSystemTools::GetFilenameName(*i); std::string fileName = cmSystemTools::GetFilenameName(*i);
std::string shortFileName = this->CTest->GetShortPathToFile(i->c_str()); std::string fullPath = cont.SourceDir + "/" + *i;
covLogFile << "\t<File Name=\"" << cmXMLSafe(fileName) covLogFile << "\t<File Name=\"" << cmXMLSafe(fileName)
<< "\" FullPath=\"" << cmXMLSafe(shortFileName) << "\">\n" << "\" FullPath=\"" << cmXMLSafe(*i) << "\">\n"
<< "\t\t<Report>" << std::endl; << "\t\t<Report>" << std::endl;
std::ifstream ifs(i->c_str()); std::ifstream ifs(fullPath.c_str());
if (!ifs) if (!ifs)
{ {
cmOStringStream ostr; cmOStringStream ostr;
ostr << "Cannot open source file: " << i->c_str(); ostr << "Cannot open source file: " << fullPath.c_str();
errorsWhileAccumulating.push_back(ostr.str()); errorsWhileAccumulating.push_back(ostr.str());
error ++; error ++;
continue; continue;
@ -611,14 +611,14 @@ int cmCTestCoverageHandler::ProcessHandler()
covLogFile << "\t\t</Report>\n\t</File>" << std::endl; covLogFile << "\t\t</Report>\n\t</File>" << std::endl;
total_untested += untested; total_untested += untested;
covSumFile << "\t<File Name=\"" << cmXMLSafe(i->c_str()) covSumFile << "\t<File Name=\"" << cmXMLSafe(fileName)
<< "\" FullPath=\"" << cmXMLSafe(shortFileName.c_str()) << "\" FullPath=\"" << cmXMLSafe(i->c_str())
<< "\" Covered=\"true\">\n" << "\" Covered=\"true\">\n"
<< "\t\t<LOCTested>0</LOCTested>\n" << "\t\t<LOCTested>0</LOCTested>\n"
<< "\t\t<LOCUnTested>" << untested << "</LOCUnTested>\n" << "\t\t<LOCUnTested>" << untested << "</LOCUnTested>\n"
<< "\t\t<PercentCoverage>0</PercentCoverage>\n" << "\t\t<PercentCoverage>0</PercentCoverage>\n"
<< "\t\t<CoverageMetric>0</CoverageMetric>\n"; << "\t\t<CoverageMetric>0</CoverageMetric>\n";
this->WriteXMLLabels(covSumFile, shortFileName); this->WriteXMLLabels(covSumFile, *i);
covSumFile << "\t</File>" << std::endl; covSumFile << "\t</File>" << std::endl;
} }
@ -628,7 +628,7 @@ int cmCTestCoverageHandler::ProcessHandler()
{ {
cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error(s) while acumulating results:" << std::endl); "Error(s) while accumulating results:" << std::endl);
std::vector<std::string>::iterator erIt; std::vector<std::string>::iterator erIt;
for ( erIt = errorsWhileAccumulating.begin(); for ( erIt = errorsWhileAccumulating.begin();
erIt != errorsWhileAccumulating.end(); erIt != errorsWhileAccumulating.end();
@ -2031,7 +2031,12 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
std::string glob = cont->SourceDir + "/" + *i; std::string glob = cont->SourceDir + "/" + *i;
gl.FindFiles(glob); gl.FindFiles(glob);
std::vector<std::string> files = gl.GetFiles(); std::vector<std::string> files = gl.GetFiles();
extraMatches.insert(files.begin(), files.end()); for(std::vector<std::string>::iterator i = files.begin();
i != files.end(); ++i)
{
extraMatches.insert(this->CTest->GetShortPathToFile(
i->c_str()));
}
} }
if(extraMatches.size()) if(extraMatches.size())
@ -2041,9 +2046,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
{ {
std::string shortPath = this->CTest->GetShortPathToFile( std::string shortPath = this->CTest->GetShortPathToFile(
i->first.c_str()); i->first.c_str());
shortPath= shortPath.substr(2, shortPath.length() - 1); extraMatches.erase(shortPath);
std::string fullPath = cont->SourceDir + "/" + shortPath;
extraMatches.erase(fullPath);
} }
} }
return extraMatches; return extraMatches;