Bug 1252995 - Add a method to get lines and name of methods. r=chmanchester

This method gets method names and the lines each method spans. It uses getAllOffsets to get the lines.

MozReview-Commit-ID: Df4kP11obq2
This commit is contained in:
Greg Mierzwinski 2016-03-11 19:18:19 -05:00
Родитель d2746f5dc8
Коммит 814949873d
1 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -123,6 +123,40 @@ CoverageCollector.prototype._getUncoveredLines = function() {
return uncoveredLines;
}
CoverageCollector.prototype._getMethodNames = function() {
let methodNames = {};
this._scripts.forEach(s => {
let method = s.displayName;
// If the method name is undefined, we return early
if (!method){
return;
}
let scriptName = s.url;
let tempMethodCov = [];
let scriptOffsets = s.getAllOffsets();
if (!methodNames[scriptName]){
methodNames[scriptName] = {};
}
/**
* Get all lines contained within the method and
* push a record of the form:
* <method name> : <lines covered>
*/
scriptOffsets.forEach(function (element, index){
if (!element){
return;
}
tempMethodCov.push(index);
});
methodNames[scriptName][method] = tempMethodCov;
});
return methodNames;
}
/**
* Records lines covered since the last time coverage was recorded,
* associating them with the given test name. The result is written