Bug 1252995 - recordTestCoverage modification. draft
authorGreg Mierzwinski <gmierz2@outlook.com>
Fri, 11 Mar 2016 19:21:36 -0500
changeset 349517 7e1cfadd4b42eb42c2a54c99ed3ad00322119535
parent 349516 c32a96933d9da5866f20b3de5b3a6bce785b1ade
child 518124 e53c7fc87e788044112dc6327b3897634a55b0d0
push id15113
push userbmo:gmierz2@outlook.com
push dateMon, 11 Apr 2016 19:30:56 +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
@@ -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'});
 }