From 614dc1bce7ee05b90c18623fef75c6658a05bade Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Fri, 11 Jun 2021 21:31:53 +0200 Subject: [PATCH] fix: propagate top level thrown errors in WPT (#10932) Previously top level errors were swallowed. --- tools/wpt/runner.ts | 14 +++++++++----- tools/wpt/testharnessreport.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts index 3a412a56c5..0cf625f011 100644 --- a/tools/wpt/runner.ts +++ b/tools/wpt/runner.ts @@ -168,9 +168,13 @@ async function generateBundle(location: URL): Promise { } } - return scriptContents.map(([url, contents]) => - `Deno.core.evalContext(${JSON.stringify(contents)}, ${ - JSON.stringify(url) - });` - ).join("\n"); + return scriptContents.map(([url, contents]) => ` +(function() { + const [_,err] = Deno.core.evalContext(${JSON.stringify(contents)}, ${ + JSON.stringify(url) + }); + if (err !== null) { + throw err?.thrown; + } +})();`).join("\n"); } diff --git a/tools/wpt/testharnessreport.js b/tools/wpt/testharnessreport.js index 04251c8524..24383a5b0c 100644 --- a/tools/wpt/testharnessreport.js +++ b/tools/wpt/testharnessreport.js @@ -18,5 +18,5 @@ window.add_completion_callback((_tests, harnessStatus) => { while (bytesWritten < data.byteLength) { bytesWritten += Deno.stderr.writeSync(data.subarray(bytesWritten)); } - Deno.exit(0); + Deno.exit(harnessStatus.status === 0 ? 0 : 1); });