1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00
denoland-deno/tools/wpt/testharnessreport.js
Luca Casonato 614dc1bce7
fix: propagate top level thrown errors in WPT (#10932)
Previously top level errors were swallowed.
2021-06-11 21:31:53 +02:00

22 lines
747 B
JavaScript

// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
window.add_result_callback(({ message, name, stack, status }) => {
const data = new TextEncoder().encode(
`${JSON.stringify({ name, status, message, stack })}\n`,
);
let bytesWritten = 0;
while (bytesWritten < data.byteLength) {
bytesWritten += Deno.stderr.writeSync(data.subarray(bytesWritten));
}
});
window.add_completion_callback((_tests, harnessStatus) => {
const data = new TextEncoder().encode(
`#$#$#${JSON.stringify(harnessStatus)}\n`,
);
let bytesWritten = 0;
while (bytesWritten < data.byteLength) {
bytesWritten += Deno.stderr.writeSync(data.subarray(bytesWritten));
}
Deno.exit(harnessStatus.status === 0 ? 0 : 1);
});