Bug 1252995 - recordTestCoverage modification.
This is a modification to recordTestCoverage. It now gathers methods and the lines each span, uncovered lines, and now also places a version control block at the beginning of every artifact.
MozReview-Commit-ID: LbpnDqheYpy
* * *
Bug 1252995 - RecordTestCoverage revision.
Fixed current issues.
* * *
Bug 1252995 - Fixed record test coverage.
--- a/testing/modules/CoverageUtils.jsm
+++ b/testing/modules/CoverageUtils.jsm
@@ -160,26 +160,43 @@ CoverageCollector.prototype._getMethodNa
/**
* 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");
let rawLines = this._getLinesCovered(testName);
+ let methods = this._getMethodNames();
+ let uncoveredLines = this._getUncoveredLines();
let result = [];
+ let versionControlBlock = {version: 1.0};
+ result.push(versionControlBlock);
+
for (let scriptName in rawLines) {
let rec = {
testUrl: testName,
sourceFile: scriptName,
- covered: []
+ methods: {},
+ covered: [],
+ uncovered: []
};
+
+ for (let methodName in methods[scriptName]){
+ rec.methods[methodName] = methods[scriptName][methodName];
+ }
+
for (let line of rawLines[scriptName]) {
rec.covered.push(line);
}
+
+ for (let line of uncoveredLines[scriptName]){
+ rec.uncovered.push(line);
+ }
+
result.push(rec);
}
let arr = this._encoder.encode(JSON.stringify(result, null, 2));
let path = this._prefix + '/' + 'jscov_' + Date.now() + '.json';
dump("Writing coverage to: " + path + "\n");
return OS.File.writeAtomic(path, arr, {tmpPath: path + '.tmp'});
}