diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts index 3886d34d55..07edcec689 100644 --- a/tools/wpt/runner.ts +++ b/tools/wpt/runner.ts @@ -82,60 +82,65 @@ export async function runSingleTest( prefix: "wpt-bundle-", suffix: ".js", }); - await Deno.writeTextFile(tempFile, bundle); - const startTime = new Date().getTime(); + try { + await Deno.writeTextFile(tempFile, bundle); - const proc = Deno.run({ - cmd: [ - denoBinary(), - "run", - "-A", - "--unstable", - "--location", - url.toString(), - "--cert", - join(ROOT_PATH, `./tools/wpt/certs/cacert.pem`), - tempFile, - "[]", - ], - env: { - NO_COLOR: "1", - }, - stdout: "null", - stderr: "piped", - }); + const startTime = new Date().getTime(); - const cases = []; - let stderr = ""; + const proc = Deno.run({ + cmd: [ + denoBinary(), + "run", + "-A", + "--unstable", + "--location", + url.toString(), + "--cert", + join(ROOT_PATH, `./tools/wpt/certs/cacert.pem`), + tempFile, + "[]", + ], + env: { + NO_COLOR: "1", + }, + stdout: "null", + stderr: "piped", + }); - let harnessStatus = null; + const cases = []; + let stderr = ""; - const lines = readLines(proc.stderr); - for await (const line of lines) { - if (line.startsWith("{")) { - const data = JSON.parse(line); - const result = { ...data, passed: data.status == 0 }; - cases.push(result); - reporter(result); - } else if (line.startsWith("#$#$#{")) { - harnessStatus = JSON.parse(line.slice(5)); - } else { - stderr += line + "\n"; - console.error(line); + let harnessStatus = null; + + const lines = readLines(proc.stderr); + for await (const line of lines) { + if (line.startsWith("{")) { + const data = JSON.parse(line); + const result = { ...data, passed: data.status == 0 }; + cases.push(result); + reporter(result); + } else if (line.startsWith("#$#$#{")) { + harnessStatus = JSON.parse(line.slice(5)); + } else { + stderr += line + "\n"; + console.error(line); + } } + + const duration = new Date().getTime() - startTime; + + const { code } = await proc.status(); + return { + status: code, + harnessStatus, + duration, + cases, + stderr, + }; + } finally { + await Deno.remove(tempFile); } - - const duration = new Date().getTime() - startTime; - - const { code } = await proc.status(); - return { - status: code, - harnessStatus, - duration, - cases, - stderr, - }; } async function generateBundle(location: URL): Promise {