Bug 1628258 - Reduce logging in reloadConsoleAndLog helper. r=jdescottes,perftest-reviewers,Bebe.

The function now only logs the missing messages after 3s, if no other
DOM updates happened.
This will probably result in having no logs if the test is successful,
while still showing the missing messages if the test is failing.

This also allow us to make the logging more correct: since we were
using an `every` function, we could bail early and not have a correct
view of what messages were missing.

Differential Revision: https://phabricator.services.mozilla.com/D70316

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2020-04-14 10:37:58 +00:00
parent 1e67f472f7
commit f3d8b676db

View File

@ -25,13 +25,18 @@ exports.reloadConsoleAndLog = async function(label, toolbox, expectedMessages) {
? [{ text: "", count: expectedMessages }]
: expectedMessages;
await waitForConsoleOutputChildListChange(hud, consoleOutputEl => {
dump("[TEST_LOG] Console output changed - checking content:\n");
const messages = Array.from(consoleOutputEl.querySelectorAll(".message"));
let logMissingMessagesTimeoutId;
await waitForConsoleOutputChildListChange(hud, consoleOutputEl => {
if (logMissingMessagesTimeoutId) {
clearTimeout(logMissingMessagesTimeoutId);
logMissingMessagesTimeoutId = null;
}
const messages = Array.from(consoleOutputEl.querySelectorAll(".message"));
const missing = new Map(expected.map(e => [e.text, e.count || 1]));
const foundAllMessages = expected.every(({ text, count = 1 }) => {
for (const { text, count = 1 } of expected) {
let found = 0;
for (const message of messages) {
const messageText = message.querySelector(".message-body").innerText;
@ -49,22 +54,22 @@ exports.reloadConsoleAndLog = async function(label, toolbox, expectedMessages) {
} else {
missing.set(text, count - found);
}
return allFound;
});
if (!foundAllMessages) {
dump(
`[TEST_LOG] Still waiting for the following messages: \n${Array.from(
missing.entries()
)
.map(([text, count]) => `${text || "<any text>"} (✕${count})`)
.join("\n")}\n`
);
} else {
dump(`[TEST_LOG] All expected messages where found\n`);
}
dump("---\n");
const foundAllMessages = missing.size == 0;
if (!foundAllMessages) {
// Only log missing messages after 3s, if there was no other DOM updates.
logMissingMessagesTimeoutId = setTimeout(() => {
dump(
`[TEST_LOG] Still waiting for the following messages: \n${Array.from(
missing.entries()
)
.map(([text, count]) => `${text || "<any text>"} (✕${count})`)
.join("\n")}\n`
);
dump("---\n");
}, 3000);
}
return foundAllMessages;
});
};