mirror of
https://github.com/denoland/deno.git
synced 2024-11-29 16:30:56 -05:00
parent
da8cb408c8
commit
070464e2cc
2 changed files with 11 additions and 26 deletions
|
@ -244,7 +244,7 @@ export class SocketReporter implements Deno.TestReporter {
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
async write(msg: any): Promise<void> {
|
async write(msg: any): Promise<void> {
|
||||||
const encodedMsg = this.encoder.encode(`${JSON.stringify(msg)}\n`);
|
const encodedMsg = this.encoder.encode(JSON.stringify(msg) + "\n");
|
||||||
await Deno.writeAll(this.conn, encodedMsg);
|
await Deno.writeAll(this.conn, encodedMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,9 @@ export class SocketReporter implements Deno.TestReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async end(msg: Deno.TestEventEnd): Promise<void> {
|
async end(msg: Deno.TestEventEnd): Promise<void> {
|
||||||
await this.write(msg);
|
const encodedMsg = this.encoder.encode(JSON.stringify(msg));
|
||||||
|
await Deno.writeAll(this.conn, encodedMsg);
|
||||||
|
this.conn.closeWrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,6 @@ async function runTestsForPermissionSet(
|
||||||
// Wait for worker subprocess to go online
|
// Wait for worker subprocess to go online
|
||||||
const conn = await listener.accept();
|
const conn = await listener.accept();
|
||||||
|
|
||||||
let err: Error | undefined = undefined;
|
|
||||||
let expectedPassedTests;
|
let expectedPassedTests;
|
||||||
let endEvent;
|
let endEvent;
|
||||||
|
|
||||||
|
@ -138,41 +137,25 @@ async function runTestsForPermissionSet(
|
||||||
if (msg.kind === Deno.TestEvent.Start) {
|
if (msg.kind === Deno.TestEvent.Start) {
|
||||||
expectedPassedTests = msg.tests;
|
expectedPassedTests = msg.tests;
|
||||||
await reporter.start(msg);
|
await reporter.start(msg);
|
||||||
continue;
|
|
||||||
} else if (msg.kind === Deno.TestEvent.TestStart) {
|
} else if (msg.kind === Deno.TestEvent.TestStart) {
|
||||||
await reporter.testStart(msg);
|
await reporter.testStart(msg);
|
||||||
continue;
|
|
||||||
} else if (msg.kind === Deno.TestEvent.TestEnd) {
|
} else if (msg.kind === Deno.TestEvent.TestEnd) {
|
||||||
await reporter.testEnd(msg);
|
await reporter.testEnd(msg);
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
endEvent = msg;
|
endEvent = msg;
|
||||||
await reporter.end(msg);
|
await reporter.end(msg);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
err = e;
|
|
||||||
} finally {
|
} finally {
|
||||||
// Close socket to worker, it should shutdown gracefully.
|
// Close socket to worker.
|
||||||
conn.close();
|
conn.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (expectedPassedTests === undefined) {
|
||||||
if (err instanceof Deno.errors.ConnectionReset) {
|
|
||||||
if (!endEvent) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof expectedPassedTests === "undefined") {
|
|
||||||
throw new Error("Worker runner didn't report start");
|
throw new Error("Worker runner didn't report start");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof endEvent === "undefined") {
|
if (endEvent === undefined) {
|
||||||
throw new Error("Worker runner didn't report end");
|
throw new Error("Worker runner didn't report end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue