Bug 1252995 - Add a method to get uncovered lines. draft
authorGreg Mierzwinski <gmierz2@outlook.com>
Fri, 11 Mar 2016 19:13:33 -0500
changeset 349515 87fcccf1d74feb474c30725bbc2c6daa815fa277
parent 348895 d9b1a9829c8ee2862955043f28183efa07de3d2b
child 349516 c32a96933d9da5866f20b3de5b3a6bce785b1ade
push id15113
push userbmo:gmierz2@outlook.com
push dateMon, 11 Apr 2016 19:30:56 +0000
bugs1252995
milestone48.0a1
Bug 1252995 - Add a method to get uncovered lines. The uncovered lines are now obtained through the use of getAllOffsets and comparing against lines that were covered. MozReview-Commit-ID: DblJeEALUq5 * * * Bug 1252995 - Uncovered Lines revision. Fixed current issues. * * * Bug 1252995 - Fixed uncovered lines. * * * Bug 1252995 - Uncovered lines method revision. Have tempUncov use set methods. * * * Bug 1252995 - Uncovered lines modification. Remove 'tempUncov'. * * * Bug 1252995 - Remove guard from duplication.
testing/modules/CoverageUtils.jsm
--- a/testing/modules/CoverageUtils.jsm
+++ b/testing/modules/CoverageUtils.jsm
@@ -88,16 +88,45 @@ CoverageCollector.prototype._getLinesCov
         this._allCoverage[scriptName][key] = currentCoverage[scriptName][key];
       }
     }
   }
 
   return coveredLines;
 }
 
+CoverageCollector.prototype._getUncoveredLines = function() {
+  let uncoveredLines = {};
+  this._scripts.forEach(s => {
+    let scriptName = s.url;
+    let scriptOffsets = s.getAllOffsets();
+
+    if (!uncoveredLines[scriptName]){
+      uncoveredLines[scriptName] = new Set();
+    }
+
+    // Get all lines in the script
+    scriptOffsets.forEach( function(element, index) {
+      if (!element){
+        return;
+      }
+      uncoveredLines[scriptName].add(index);
+    });
+  });
+
+  // For all covered lines, delete their entry
+  for (let scriptName in this._allCoverage){
+    for (let key in this._allCoverage[scriptName]){
+      let [lineNumber, columnNumber, offset] = key.split('#');
+      uncoveredLines[scriptName].delete(parseInt(lineNumber, 10));
+    }
+  }
+
+  return uncoveredLines;
+}
 
 /**
  * Records lines covered since the last time coverage was recorded,
  * associating them with the given test name. The result is written
  * to a json file in a specified directory.
  */
 CoverageCollector.prototype.recordTestCoverage = function (testName) {
   dump("Collecting coverage for: " + testName + "\n");