summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/wpt/runner.ts105
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> {