Bug 1252995 - recordTestCoverage modification. draft
authorGreg Mierzwinski <gmierz2@outlook.com>
Fri, 11 Mar 2016 19:21:36 -0500
changeset 348548 2a633a435b2d284bcd21c7930550dac1508a7f2c
parent 348547 3fd5326154e05dd8b6e6d62991e5e0c7d89fe6ed
child 517869 096827d2db4360ea636d285c71e2312e60e3d439
push id14847
push userbmo:gmierz2@outlook.com
push dateThu, 07 Apr 2016 18:44:37 +0000
bugs1252995
milestone48.0a1
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.
testing/modules/CoverageUtils.jsm
--- a/testing/modules/CoverageUtils.jsm
+++ b/testing/modules/CoverageUtils.jsm
@@ -173,26 +173,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'});
 }