From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../reporters/mozilla-format.js | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js (limited to 'tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js') 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..a3f96e7bef --- /dev/null +++ b/tools/lint/eslint/eslint-plugin-mozilla/reporters/mozilla-format.js @@ -0,0 +1,57 @@ +/* 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 = []; + + 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.push(test); + // 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 + }` + ); + mocha.reporters.Base.list([test]); + }); + + runner.on("end", function () { + // Space the results out visually with an additional blank line. + console.log(""); + console.log("INFO | Result summary:"); + console.log(`INFO | Passed: ${passes}`); + console.log(`INFO | Failed: ${failures.length}`); + console.log("SUITE-END"); + // Space the failures out visually with an additional blank line. + console.log(""); + console.log("Failure summary:"); + mocha.reporters.Base.list(failures); + process.exit(failures.length); + }); +} -- cgit v1.2.3