summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoni Choudhury <roni.choudhury@kitware.com>2014-05-24 15:42:08 (GMT)
committerBrad King <brad.king@kitware.com>2014-05-28 16:25:28 (GMT)
commit88b3dcb125db2c3ae64b69d74a9f58b3425012d0 (patch)
tree855c81d9c50c9e379765640f79e1dba7137a574c
parent8ae05b420e513252d1fd68dc6085d8dd92f3e624 (diff)
downloadCMake-88b3dcb125db2c3ae64b69d74a9f58b3425012d0.zip
CMake-88b3dcb125db2c3ae64b69d74a9f58b3425012d0.tar.gz
CMake-88b3dcb125db2c3ae64b69d74a9f58b3425012d0.tar.bz2
CTest: Improve Python coverage.py source file search algorithm
If the coverage.py source file is not found in the source directory, the build directory is first searched before raising an error. This is necessary because it is a valid workflow to build a Python package from source, then install this package to a virtualenv that lives in the build directory. Tests will run against this deployed package and therefore the covered source files will be found in a subdirectory of the build directory, and not anywhere in the source directory.
-rw-r--r--Source/CTest/cmParsePythonCoverage.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx
index 2578bb8..68a6817 100644
--- a/Source/CTest/cmParsePythonCoverage.cxx
+++ b/Source/CTest/cmParsePythonCoverage.cxx
@@ -33,19 +33,25 @@ protected:
<< atts[tagCount+1] << std::endl);
this->CurFileName = this->Coverage.SourceDir + "/" +
atts[tagCount+1];
- FileLinesType& curFileLines =
- this->Coverage.TotalCoverage[this->CurFileName];
cmsys::ifstream fin(this->CurFileName.c_str());
if(!fin)
{
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Python Coverage: Error opening " << this->CurFileName
- << std::endl);
- this->Coverage.Error++;
- break;
+ this->CurFileName = this->Coverage.BinaryDir + "/" +
+ atts[tagCount+1];
+ fin.open(this->CurFileName.c_str());
+ if (!fin)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Python Coverage: Error opening " << this->CurFileName
+ << std::endl);
+ this->Coverage.Error++;
+ break;
+ }
}
std::string line;
+ FileLinesType& curFileLines =
+ this->Coverage.TotalCoverage[this->CurFileName];
curFileLines.push_back(-1);
while(cmSystemTools::GetLineFromStream(fin, line))
{