diff options
author | Andreu Botella <abb@randomunok.com> | 2021-06-24 21:07:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-24 15:07:36 -0400 |
commit | be5d2983b41f6a650b7e2f5d986b67e801454d6d (patch) | |
tree | acee835d9aa0166af588e9ef49f6ff1096902e76 | |
parent | 586586b7911088086c99dfeb5a4b082dc1393c62 (diff) |
chore(wpt): clean up temporary files created by the WPT test runner (#11108)
Fixes #11107.
-rw-r--r-- | tools/wpt/runner.ts | 105 |
1 files changed, 55 insertions, 50 deletions
diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts index 3886d34d5..07edcec68 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(); - - 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 cases = []; - let stderr = ""; - - 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); + try { + await Deno.writeTextFile(tempFile, bundle); + + const startTime = new Date().getTime(); + + 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 cases = []; + let stderr = ""; + + 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 duration = new Date().getTime() - startTime; - const { code } = await proc.status(); - return { - status: code, - harnessStatus, - duration, - cases, - stderr, - }; + const { code } = await proc.status(); + return { + status: code, + harnessStatus, + duration, + cases, + stderr, + }; + } finally { + await Deno.remove(tempFile); + } } async function generateBundle(location: URL): Promise<string> { |