summaryrefslogtreecommitdiffstats
path: root/tools/lint/eslint/eslint-plugin-mozilla/reporters
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lint/eslint/eslint-plugin-mozilla/reporters')
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
new file mode 100644
index 0000000000..885727e8aa
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js
@@ -0,0 +1,50 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * 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);
+ });
+}