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.
--- 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");