зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1801368 - Migrate StructuredLog.jsm to an ES module. r=ahal
Depends on D162490 Differential Revision: https://phabricator.services.mozilla.com/D162491
This commit is contained in:
Родитель
55d53c8bb7
Коммит
4a8185fb14
|
@ -156,7 +156,7 @@ add_test(function test_categoryRegistration()
|
|||
const XULAPPINFO_CID = Components.ID("{fc937916-656b-4fb3-a395-8c63569e27a8}");
|
||||
|
||||
// Create a fake app entry for our category registration apps filter.
|
||||
let { newAppInfo } = ChromeUtils.import("resource://testing-common/AppInfo.jsm");
|
||||
let { newAppInfo } = ChromeUtils.importESModule("resource://testing-common/AppInfo.sys.mjs");
|
||||
let XULAppInfo = newAppInfo({
|
||||
name: "catRegTest",
|
||||
ID: "{adb42a9a-0d19-4849-bf4d-627614ca19be}",
|
||||
|
|
|
@ -53,7 +53,7 @@ reftest.jar:
|
|||
res/ReftestFissionChild.jsm (ReftestFissionChild.jsm)
|
||||
res/AsyncSpellCheckTestHelper.jsm (../../../editor/AsyncSpellCheckTestHelper.jsm)
|
||||
res/httpd.jsm (../../../netwerk/test/httpserver/httpd.js)
|
||||
res/StructuredLog.jsm (../../../testing/modules/StructuredLog.jsm)
|
||||
res/StructuredLog.sys.mjs (../../../testing/modules/StructuredLog.sys.mjs)
|
||||
res/PerTestCoverageUtils.jsm (../../../tools/code-coverage/PerTestCoverageUtils.jsm)
|
||||
res/input.css (../../../editor/reftests/xul/input.css)
|
||||
res/progress.css (../../../layout/reftests/forms/progress/style.css)
|
||||
|
|
|
@ -48,8 +48,8 @@ const { HttpServer } = ChromeUtils.import("resource://reftest/httpd.jsm");
|
|||
const { ReadTopManifest, CreateUrls } = ChromeUtils.import(
|
||||
"resource://reftest/manifest.jsm"
|
||||
);
|
||||
const { StructuredLogger } = ChromeUtils.import(
|
||||
"resource://reftest/StructuredLog.jsm"
|
||||
const { StructuredLogger } = ChromeUtils.importESModule(
|
||||
"resource://reftest/StructuredLog.sys.mjs"
|
||||
);
|
||||
const { PerTestCoverageUtils } = ChromeUtils.import(
|
||||
"resource://reftest/PerTestCoverageUtils.jsm"
|
||||
|
|
|
@ -45,7 +45,7 @@ FINAL_TARGET_FILES.content.static += [
|
|||
|
||||
FINAL_TARGET_FILES.content.tests.SimpleTest += [
|
||||
"../../docshell/test/chrome/docshell_helpers.js",
|
||||
"../modules/StructuredLog.jsm",
|
||||
"../modules/StructuredLog.sys.mjs",
|
||||
"tests/SimpleTest/AccessibilityUtils.js",
|
||||
"tests/SimpleTest/EventUtils.js",
|
||||
"tests/SimpleTest/ExtensionTestUtils.js",
|
||||
|
|
|
@ -766,10 +766,6 @@ function testListing(metadata, response) {
|
|||
type: "text/css",
|
||||
href: "/static/harness.css",
|
||||
}),
|
||||
SCRIPT({
|
||||
type: "text/javascript",
|
||||
src: "/tests/SimpleTest/StructuredLog.jsm",
|
||||
}),
|
||||
SCRIPT({
|
||||
type: "text/javascript",
|
||||
src: "/tests/SimpleTest/LogController.js",
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
// This file expects the following files to be loaded.
|
||||
/* import-globals-from ../../../modules/StructuredLog.jsm */
|
||||
/* import-globals-from LogController.js */
|
||||
/* import-globals-from MemoryStats.js */
|
||||
/* import-globals-from MozillaLogger.js */
|
||||
|
@ -16,6 +15,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
StructuredLogger,
|
||||
StructuredFormatter,
|
||||
} = SpecialPowers.ChromeUtils.importESModule(
|
||||
"resource://testing-common/StructuredLog.sys.mjs"
|
||||
);
|
||||
|
||||
function getElement(id) {
|
||||
return typeof id == "string" ? document.getElementById(id) : id;
|
||||
}
|
||||
|
@ -337,7 +343,9 @@ TestRunner._dumpMessage = function(message) {
|
|||
// From https://searchfox.org/mozilla-central/source/testing/modules/StructuredLog.jsm
|
||||
TestRunner.structuredLogger = new StructuredLogger(
|
||||
"mochitest",
|
||||
TestRunner._dumpMessage
|
||||
TestRunner._dumpMessage,
|
||||
[],
|
||||
TestRunner
|
||||
);
|
||||
TestRunner.structuredLogger.deactivateBuffering = function() {
|
||||
TestRunner.structuredLogger.logData("buffering_off");
|
||||
|
|
|
@ -2,27 +2,28 @@
|
|||
* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["StructuredLogger", "StructuredFormatter"];
|
||||
|
||||
/**
|
||||
* TestLogger: Logger class generating messages compliant with the
|
||||
* structured logging protocol for tests exposed by mozlog
|
||||
*
|
||||
* @param name
|
||||
* @param {string} name
|
||||
* The name of the logger to instantiate.
|
||||
* @param dumpFun
|
||||
* @param {function} [dumpFun]
|
||||
* An underlying function to be used to log raw messages. This function
|
||||
* will receive the complete serialized json string to log.
|
||||
* @param {object} [scope]
|
||||
* The scope that the dumpFun is loaded in, so that messages are cloned
|
||||
* into that scope before passing them.
|
||||
*/
|
||||
class StructuredLogger {
|
||||
export class StructuredLogger {
|
||||
name = null;
|
||||
#dumpFun = null;
|
||||
#dumpScope = null;
|
||||
|
||||
constructor(name, dumpFun = dump) {
|
||||
constructor(name, dumpFun = dump, scope = null) {
|
||||
this.name = name;
|
||||
this.#dumpFun = dumpFun;
|
||||
this.#dumpScope = scope;
|
||||
}
|
||||
|
||||
testStart(test) {
|
||||
|
@ -210,7 +211,11 @@ class StructuredLogger {
|
|||
allData[field] = data[field];
|
||||
}
|
||||
|
||||
this.#dumpFun(allData);
|
||||
if (this.#dumpScope) {
|
||||
this.#dumpFun(Cu.cloneInto(allData, this.#dumpScope));
|
||||
} else {
|
||||
this.#dumpFun(allData);
|
||||
}
|
||||
}
|
||||
|
||||
#testId(test) {
|
||||
|
@ -225,7 +230,7 @@ class StructuredLogger {
|
|||
* StructuredFormatter: Formatter class turning structured messages
|
||||
* into human-readable messages.
|
||||
*/
|
||||
class StructuredFormatter {
|
||||
export class StructuredFormatter {
|
||||
// The time at which the whole suite of tests started.
|
||||
#suiteStartTime = null;
|
||||
|
|
@ -16,7 +16,7 @@ TESTING_JS_MODULES += [
|
|||
"MockRegistrar.sys.mjs",
|
||||
"sinon-7.2.7.js",
|
||||
"Sinon.jsm",
|
||||
"StructuredLog.jsm",
|
||||
"StructuredLog.sys.mjs",
|
||||
"TestUtils.sys.mjs",
|
||||
"XPCShellContentUtils.sys.mjs",
|
||||
]
|
||||
|
@ -27,7 +27,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
|
|||
]
|
||||
|
||||
|
||||
TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += ["StructuredLog.jsm"]
|
||||
TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += ["StructuredLog.sys.mjs"]
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Testing", "General")
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function run_test() {
|
||||
const { StructuredLogger } = ChromeUtils.import(
|
||||
"resource://testing-common/StructuredLog.jsm"
|
||||
const { StructuredLogger } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/StructuredLog.sys.mjs"
|
||||
);
|
||||
|
||||
let testBuffer = [];
|
||||
|
|
|
@ -90,8 +90,8 @@ var _dumpLog = function(raw_msg) {
|
|||
dump("\n" + JSON.stringify(raw_msg) + "\n");
|
||||
};
|
||||
|
||||
var { StructuredLogger: _LoggerClass } = ChromeUtils.import(
|
||||
"resource://testing-common/StructuredLog.jsm"
|
||||
var { StructuredLogger: _LoggerClass } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/StructuredLog.sys.mjs"
|
||||
);
|
||||
var _testLogger = new _LoggerClass("xpcshell/head.js", _dumpLog, [_add_params]);
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ AddonTestUtils.createAppInfo(
|
|||
const { ExtensionScriptingStore } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionScriptingStore.jsm"
|
||||
);
|
||||
const { TestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/TestUtils.jsm"
|
||||
const { TestUtils } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/TestUtils.sys.mjs"
|
||||
);
|
||||
|
||||
const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm");
|
||||
|
|
Загрузка…
Ссылка в новой задаче