Files
palemoon27/testing/modules/StructuredLog.jsm
T
roytam1 78ceb79db1 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1248863 - IonMonkey: MIPS: Fix MDefinition::constantValue re-factored. r=luke (c38ce4f8dd)
- Bug 1231024 - narrow the live range for values. r=jandem (bfe06e964d)
- Bug 1248007 part 1 - Refactor useBox and friends to work more like useRegister. r=nbp (8585828647)
- Bug 1248007 part 2 - Remove unused This operands from LCallDirectEval. r=nbp (ca16fc594e)
- Bug 1248598 part 3 - Enable i64 on x64 and various related changes. r=sunfish (75311df85c)
- Bug 1248863 - IonMonkey: MIPS32: Fix LIRGeneratorMIPS::visitBox. r=arai (2d6f64ed18)
- Bug 1244889 - Handle all SIMD types in js::SimdTypeToName. r=bbouvier (7e8952b52d)
- Bug 1244889 - Add support for Uint32x4 as an asm.js type. r=luke (cab8e0e725)
- Bug 1244889 - Fix Float32x4toUint32x4 for asm.js. r=bbouvier (3b34875729)
- Bug 1244889 - Disallow unsigned SIMD types for global variables. r=luke (cde605325d)
- Bug 1201934 - Remove SIMD shiftRight***ByScalar. r=sunfish (db2a308c6f)
- Bug 1246800 - Masked shift-by-scalar amounts. r=sunfish (58f335a1cf)
- Bug 1226017 - Drop support for b2g desktop in reftests, r=jgriffin (b71bfbea26)
- Bug 1231261 - Append plugins to extra profile files instead of overwriting. r=dbaron (cce158e2bf)
- Bug 1193223 - Add reftest support to mach test, r=chmanchester (44e12e1622)
- Bug 1087791 - Add |mach {reftest,crashtest,jstestbrowser}| for mobile/android. r=nalexander (711a6eb376)
- Bug 1087791 - Follow-up on 340c1df41b69 (pushed wrong version of patch); r=nalexander (d4e7b53834)
- Bug 1228636 - Add mach support for running reftests on mulet, r=jgriffin (25fa23feb4)
- Bug 1232792 - Convert JS callsites to use open2 within layout/ (r=sicking) (8ee4616658)
- Bug 1196831 - Add 'run-until-failure' and 'repeat' flags to reftest. r=jmaher (7792c9fa22)
- Bug 1215148 - Object-count based leak checking for Mochitest. r=jgriffin (afe3a307b2)
- Bug 1219371 - Add suppression for Aurora-only Windows leak. r=erahm (2e74e92da2)
- Bug 1218393 - Give a summary for object-count leak checking. r=jgriffin (b1bd4844e9)
- Bug 1219919 - Add suppressions for Windows-specific content process graphics leaks. r=erahm (a651f412b3)
- Bug 1140394 - Protect standard output from interleaving. r=ahal (0ef5d8f71f)
- Bug 1034290 - Use structured log output for test results in reftest, r=jmaher (3e93bd862b)
- Bug 1249787 - OdinMonkey: Add offset and align fields to the encoding of load and store. r=luke (822e9b01f9)
- Bug 1248203 - streamline h2 stream flow control buffer r=hurley (739a39a255)
- Bug 1221320 - XMLHttpRequest authentication should not require auth prompt dialog, r=honzab.moz (12d9bcc6d0)
- Bug 1158543 - Remove SpdyConnectTransaction::mRequestHead and make the base class mRequestHead protected; r=mcmanus (9678015004)
- Bug 844948 - Allow changing padding of themed button on OS X. r=mstange,heycam (56cbcffbfe)
- Bug 1248983 - Fix spelling for nsCocoaWindow.mm. r=jdm (e185ad5889)
- Bug 917505 - Add WEBGL_compressed_texture_es3 support. r=jgilbert r=smaug (bf4ef11229)
- Bug 1243072 - Make GfxTexturesReporter work again r=nical,jgilbert (6942d70ecf)
2023-09-25 10:10:09 +08:00

247 lines
6.0 KiB
JavaScript

/* 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/. */
"use strict";
this.EXPORTED_SYMBOLS = [
"StructuredLogger",
"StructuredFormatter"
];
/**
* TestLogger: Logger class generating messages compliant with the
* structured logging protocol for tests exposed by mozlog
*
* @param name
* The name of the logger to instantiate.
* @param dumpFun
* An underlying function to be used to log raw messages. This function
* will receive the complete serialized json string to log.
* @param mutators
* An array of functions used to add global context to log messages.
* These will each be called with the complete object to log as an
* argument.
*/
this.StructuredLogger = function(name, dumpFun=dump, mutators=[]) {
this.name = name;
this._dumpFun = dumpFun;
this._mutatorFuns = mutators;
}
/**
* Log functions producing messages in the format specified by mozlog
*/
StructuredLogger.prototype = {
testStart: function (test) {
var data = {test: test};
this._logData("test_start", data);
},
testStatus: function (test, subtest, status, expected="PASS",
message=null, stack=null, extra=null) {
if (subtest === null || subtest === undefined) {
// Fix for assertions that don't pass in a name
subtest = "undefined assertion name";
}
var data = {
test: test,
subtest: subtest,
status: status,
};
if (expected != status && status != "SKIP") {
data.expected = expected;
}
if (message !== null) {
data.message = String(message);
}
if (stack !== null) {
data.stack = stack;
}
if (extra !== null) {
data.extra = extra;
}
this._logData("test_status", data);
},
testEnd: function (test, status, expected="OK", message=null, stack=null, extra=null) {
var data = {test: test, status: status};
if (expected != status && status != "SKIP") {
data.expected = expected;
}
if (message !== null) {
data.message = String(message);
}
if (stack !== null) {
data.stack = stack;
}
if (extra !== null) {
data.extra = extra;
}
this._logData("test_end", data);
},
suiteStart: function (tests, runinfo=null, versioninfo=null, deviceinfo=null, extra=null) {
var data = {tests: tests};
if (runinfo !== null) {
data.runinfo = runinfo;
}
if (versioninfo !== null) {
data.versioninfo = versioninfo;
}
if (deviceinfo !== null) {
data.deviceinfo = deviceinfo;
}
if (extra !== null) {
data.extra = extra;
}
this._logData("suite_start", data);
},
suiteEnd: function (extra=null) {
var data = {};
if (extra !== null) {
data.extra = extra;
}
this._logData("suite_end", data);
},
/**
* Unstructured logging functions. The "extra" parameter can always by used to
* log suite specific data. If a "stack" field is provided it is logged at the
* top level of the data object for the benefit of mozlog's formatters.
*/
log: function (level, message, extra=null) {
var data = {
level: level,
message: String(message),
};
if (extra !== null) {
data.extra = extra;
if ("stack" in extra) {
data.stack = extra.stack;
}
}
this._logData("log", data);
},
debug: function (message, extra=null) {
this.log("DEBUG", message, extra);
},
info: function (message, extra=null) {
this.log("INFO", message, extra);
},
warning: function (message, extra=null) {
this.log("WARNING", message, extra);
},
error: function (message, extra=null) {
this.log("ERROR", message, extra);
},
critical: function (message, extra=null) {
this.log("CRITICAL", message, extra);
},
processOutput: function(thread, message) {
this._logData('process_output', {
message: message,
thread: thread,
});
},
_logData: function (action, data={}) {
var allData = {
action: action,
time: Date.now(),
thread: null,
pid: null,
source: this.name
};
for (var field in data) {
allData[field] = data[field];
}
for (var fun of this._mutatorFuns) {
fun(allData);
}
this._dumpFun(allData);
}
};
/**
* StructuredFormatter: Formatter class turning structured messages
* into human-readable messages.
*/
this.StructuredFormatter = function() {
this.testStartTimes = {};
};
StructuredFormatter.prototype = {
log: function(message) {
return message.message;
},
suite_start: function(message) {
this.suiteStartTime = message.time;
return "SUITE-START | Running " + message.tests.length + " tests";
},
test_start: function(message) {
this.testStartTimes[message.test] = new Date().getTime();
return "TEST-START | " + message.test;
},
test_status: function(message) {
var statusInfo = message.test + " | " + message.subtest +
(message.message ? " | " + message.message : "");
if (message.expected) {
return "TEST-UNEXPECTED-" + message.status + " | " + statusInfo +
" - expected: " + message.expected;
} else {
return "TEST-" + message.status + " | " + statusInfo;
}
},
test_end: function(message) {
var startTime = this.testStartTimes[message.test];
delete this.testStartTimes[message.test];
var statusInfo = message.test + (message.message ? " | " + String(message.message) : "");
var result;
if (message.expected) {
result = "TEST-UNEXPECTED-" + message.status + " | " + statusInfo +
" - expected: " + message.expected;
} else {
return "TEST-" + message.status + " | " + statusInfo;
}
result = " | took " + message.time - startTime + "ms";
},
suite_end: function(message) {
return "SUITE-END | took " + message.time - this.suiteStartTime + "ms";
}
};