summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestCoverageHandler.cxx
diff options
context:
space:
mode:
authorJoseph Snyder <joe.snyder@kitware.com>2015-11-16 21:27:57 (GMT)
committerBrad King <brad.king@kitware.com>2015-11-23 17:41:36 (GMT)
commit32268810d9f1cf40d20bfb287be30db582696043 (patch)
treecde53c9bddb1a5188fdba365133d184fd6176297 /Source/CTest/cmCTestCoverageHandler.cxx
parent30b0db7bb5482258ccdb96d2f0b7aadb5d3b23ac (diff)
downloadCMake-32268810d9f1cf40d20bfb287be30db582696043.zip
CMake-32268810d9f1cf40d20bfb287be30db582696043.tar.gz
CMake-32268810d9f1cf40d20bfb287be30db582696043.tar.bz2
CTest: Expand directories for Cobertura search
Change the Cobertura handler to look for an environment variable called "COBERTURADIR" which contains the directory where the coverage.xml file is found. If that variable doesn't exist, continue to use the default of the binary directory. Update the test to use an appropriate value in the environment variables.
Diffstat (limited to 'Source/CTest/cmCTestCoverageHandler.cxx')
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 6027502..2c2cd48 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -820,11 +820,26 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
{
cmParseCoberturaCoverage cov(*cont, this->CTest);
- // Assume the coverage.xml is in the source directory
- std::string coverageXMLFile = this->CTest->GetBinaryDir() + "/coverage.xml";
+ // Assume the coverage.xml is in the binary directory
+ // check for the COBERTURADIR environment variable,
+ // if it doesn't exist or is empty, assume the
+ // binary directory is used.
+ std::string coverageXMLFile;
+ const char* covDir = cmSystemTools::GetEnv("COBERTURADIR");
+ if(covDir && strlen(covDir) != 0)
+ {
+ coverageXMLFile = std::string(covDir);
+ }
+ else
+ {
+ coverageXMLFile = this->CTest->GetBinaryDir();
+ }
+ // build the find file string with the directory from above
+ coverageXMLFile += "/coverage.xml";
if(cmSystemTools::FileExists(coverageXMLFile.c_str()))
{
+ // If file exists, parse it
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cobertura XML file: " << coverageXMLFile
<< std::endl, this->Quiet);
@@ -833,7 +848,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
else
{
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Cannot find Cobertura XML file: " << coverageXMLFile
+ " Cannot find Cobertura XML file: " << coverageXMLFile
<< std::endl, this->Quiet);
}
return static_cast<int>(cont->TotalCoverage.size());