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.
This commit is contained in:
parent
8ae05b420e
commit
88b3dcb125
|
@ -33,10 +33,13 @@ 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)
|
||||
{
|
||||
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
|
||||
|
@ -44,8 +47,11 @@ protected:
|
|||
this->Coverage.Error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string line;
|
||||
FileLinesType& curFileLines =
|
||||
this->Coverage.TotalCoverage[this->CurFileName];
|
||||
curFileLines.push_back(-1);
|
||||
while(cmSystemTools::GetLineFromStream(fin, line))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue