Bug 1379119 - Add a mozilla specific reporter for mocha when used with eslint-plugin-mozilla to be compatible with treeherder. r=ahal
authorMark Banner <standard8@mozilla.com>
Mon, 10 Jul 2017 17:08:53 +0100
changeset 417181 0817ffe9bc47f303fc7138698abf92e4e1d5bdea
parent 417180 3b419fb92d30ac90c342e803aec3f3384a173df9
child 417182 c503bc4cdc9d529514eef359a97a5a6321a4cdb1
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1379119
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1379119 - Add a mozilla specific reporter for mocha when used with eslint-plugin-mozilla to be compatible with treeherder. r=ahal MozReview-Commit-ID: 3QVaSXAfa1F
tools/lint/eslint/eslint-plugin-mozilla/package.json
tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -23,24 +23,25 @@
     "escope": "^3.6.0",
     "espree": "^3.4.0",
     "estraverse": "^4.2.0",
     "globals": "^9.14.0",
     "ini-parser": "^0.0.2",
     "sax": "^1.2.2"
   },
   "devDependencies": {
+    "eslint": "^4.2.0",
     "mocha": "3.2.0"
   },
   "peerDependencies": {
     "eslint": "^3.0.0 || ^4.0.0",
     "eslint-plugin-no-unsanitized": "^2.0.1"
   },
   "engines": {
     "node": ">=6.9.1"
   },
   "scripts": {
     "prepack": "node scripts/createExports.js",
-    "test": "mocha -R dot tests",
+    "test": "mocha -R dot --reporter 'reporters/mozilla-format.js' tests",
     "postpublish": "rm -f lib/modules.json lib/environments/saved-globals.json"
   },
   "license": "MPL-2.0"
 }
new file mode 100644
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
@@ -0,0 +1,42 @@
+/**
+ * This file outputs the format that treeherder requires. If we integrate
+ * these tests with ./mach, then we may replace this with a json handler within
+ * mach itself.
+ */
+
+"use strict";
+
+var mocha = require("mocha");
+var path = require("path");
+module.exports = MozillaFormatter;
+
+function MozillaFormatter(runner) {
+  mocha.reporters.Base.call(this, runner);
+  var passes = 0;
+  var failures = 0;
+
+  runner.on("start", () => {
+    console.log("SUITE-START | eslint-plugin-mozilla");
+  });
+
+  runner.on("pass", function(test) {
+    passes++;
+    let title = test.title.replace(/\n/g, "|");
+    console.log(`TEST-PASS | ${path.basename(test.file)} | ${title}`);
+  });
+
+  runner.on("fail", function(test, err) {
+    failures++;
+    // Replace any newlines in the title.
+    let title = test.title.replace(/\n/g, "|");
+    console.log(`TEST-UNEXPECTED-FAIL | ${path.basename(test.file)} | ${title} | ${err.message}`);
+  });
+
+  runner.on("end", function() {
+    console.log("INFO | Result summary:");
+    console.log(`INFO | Passed: ${passes}`);
+    console.log(`INFO | Failed: ${failures}`);
+    console.log("SUITE-END");
+    process.exit(failures);
+  });
+}