Browse Source

Merge topic 'fix-coverage-py'

deee7c42 CTest: Fix Python coverage.py off-by-one error in results
88b3dcb1 CTest: Improve Python coverage.py source file search algorithm
Brad King 11 years ago
parent
commit
574f096b9a
1 changed files with 15 additions and 9 deletions
  1. 15 9
      Source/CTest/cmParsePythonCoverage.cxx

+ 15 - 9
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))
           {
@@ -73,11 +79,11 @@ protected:
           curNumber = atoi(atts[tagCount+1]);
         }
 
-        if(curHits > -1 && curNumber > -1)
+        if(curHits > -1 && curNumber > 0)
         {
           FileLinesType& curFileLines =
             this->Coverage.TotalCoverage[this->CurFileName];
-          curFileLines[curNumber] = curHits;
+          curFileLines[curNumber-1] = curHits;
           break;
         }
         ++tagCount;