Bug 1252995 - Add a method to get uncovered lines. r=chmanchester
authorGreg Mierzwinski <gmierz2@outlook.com>
Fri, 11 Mar 2016 19:13:33 -0500
changeset 331160 b72f1f574abadf0ff5c64cb8814a6b52c31d2940
parent 331159 557559847ec748518993c28da60ba2026a919aa6
child 331161 1602320ae20876e40c82b6d936dae74cf28ab02b
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1252995
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1252995 - Add a method to get uncovered lines. r=chmanchester The uncovered lines are now obtained through the use of getAllOffsets and comparing against lines that were covered. MozReview-Commit-ID: DblJeEALUq5
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");