mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-06 21:25:58 +00:00
Switch to message protocol
Switches the WebGPU CTS test runner JavaScript code to use the defined message protocol instead of the ad-hoc solution we were using before. Bug: chromium:1340602 Change-Id: Ieaf26b5b2409f69d7859d3db4ce7757780de6712 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98684 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org> Auto-Submit: Brian Sheedy <bsheedy@google.com>
This commit is contained in:
parent
6af4c8b97d
commit
0653501212
@ -55,6 +55,7 @@ async function runCtsTest(query, use_worker) {
|
||||
const name = testcase.query.toString();
|
||||
|
||||
const wpt_fn = async () => {
|
||||
sendMessageTestStarted();
|
||||
const [rec, res] = log.record(name);
|
||||
if (worker) {
|
||||
await worker.run(rec, name, expectations);
|
||||
@ -62,8 +63,19 @@ async function runCtsTest(query, use_worker) {
|
||||
await testcase.run(rec, expectations);
|
||||
}
|
||||
|
||||
sendMessageTestStatus(res.status, res.timems);
|
||||
|
||||
let fullLogs = (res.logs ?? []).map(prettyPrintLog);
|
||||
fullLogs = fullLogs.join('\n\n\n');
|
||||
let logPieces = splitLogsForPayload(fullLogs);
|
||||
sendMessageTestLog(logPieces);
|
||||
sendMessageTestFinished();
|
||||
};
|
||||
await wpt_fn();
|
||||
}
|
||||
}
|
||||
|
||||
function splitLogsForPayload(fullLogs) {
|
||||
let logPieces = [fullLogs]
|
||||
// Split the log pieces until they all are guaranteed to fit into a
|
||||
// websocket payload.
|
||||
@ -84,18 +96,28 @@ async function runCtsTest(query, use_worker) {
|
||||
}
|
||||
logPieces = tempLogPieces;
|
||||
}
|
||||
return logPieces
|
||||
}
|
||||
|
||||
logPieces.forEach((piece, index, arr) => {
|
||||
let isFinal = index == arr.length - 1;
|
||||
socket.send(JSON.stringify({'s': res.status,
|
||||
'l': piece,
|
||||
'final': isFinal,
|
||||
'js_duration_ms': res.timems,
|
||||
'type': 'TEST_FINISHED'}));
|
||||
function sendMessageTestStarted() {
|
||||
socket.send(JSON.stringify({'type': 'TEST_STARTED'}));
|
||||
}
|
||||
|
||||
function sendMessageTestStatus(status, jsDurationMs) {
|
||||
socket.send(JSON.stringify({'type': 'TEST_STATUS',
|
||||
'status': status,
|
||||
'js_duration_ms': jsDurationMs}));
|
||||
}
|
||||
|
||||
function sendMessageTestLog(logPieces) {
|
||||
logPieces.forEach((piece) => {
|
||||
socket.send(JSON.stringify({'type': 'TEST_LOG',
|
||||
'log': piece}));
|
||||
});
|
||||
};
|
||||
await wpt_fn();
|
||||
}
|
||||
}
|
||||
|
||||
function sendMessageTestFinished() {
|
||||
socket.send(JSON.stringify({'type': 'TEST_FINISHED'}));
|
||||
}
|
||||
|
||||
window.runCtsTest = runCtsTest;
|
||||
|
Loading…
x
Reference in New Issue
Block a user