diff --git a/cli/js/tests/test_util.ts b/cli/js/tests/test_util.ts index 9b166974477bb4..621d86bfd7f251 100644 --- a/cli/js/tests/test_util.ts +++ b/cli/js/tests/test_util.ts @@ -244,7 +244,7 @@ export class SocketReporter implements Deno.TestReporter { // eslint-disable-next-line @typescript-eslint/no-explicit-any async write(msg: any): Promise { - const encodedMsg = this.encoder.encode(`${JSON.stringify(msg)}\n`); + const encodedMsg = this.encoder.encode(JSON.stringify(msg) + "\n"); await Deno.writeAll(this.conn, encodedMsg); } @@ -270,7 +270,9 @@ export class SocketReporter implements Deno.TestReporter { } async end(msg: Deno.TestEventEnd): Promise { - await this.write(msg); + const encodedMsg = this.encoder.encode(JSON.stringify(msg)); + await Deno.writeAll(this.conn, encodedMsg); + this.conn.closeWrite(); } } diff --git a/cli/js/tests/unit_test_runner.ts b/cli/js/tests/unit_test_runner.ts index dc0ad3e1952eaa..b34afabf053491 100755 --- a/cli/js/tests/unit_test_runner.ts +++ b/cli/js/tests/unit_test_runner.ts @@ -101,7 +101,7 @@ function spawnWorkerRunner( args.push(filter); } - const ioMode = verbose ? "inherit" : "null"; + const ioMode = verbose ? "inherit" : "inherit"; const p = Deno.run({ args, @@ -127,7 +127,6 @@ async function runTestsForPermissionSet( // Wait for worker subprocess to go online const conn = await listener.accept(); - let err: Error | undefined = undefined; let expectedPassedTests; let endEvent; @@ -138,41 +137,25 @@ async function runTestsForPermissionSet( if (msg.kind === Deno.TestEvent.Start) { expectedPassedTests = msg.tests; await reporter.start(msg); - continue; } else if (msg.kind === Deno.TestEvent.TestStart) { await reporter.testStart(msg); - continue; } else if (msg.kind === Deno.TestEvent.TestEnd) { await reporter.testEnd(msg); - continue; } else { endEvent = msg; await reporter.end(msg); - break; } } - } catch (e) { - err = e; } finally { - // Close socket to worker, it should shutdown gracefully. + // Close socket to worker. conn.close(); } - if (err) { - if (err instanceof Deno.errors.ConnectionReset) { - if (!endEvent) { - throw err; - } - } else { - throw err; - } - } - - if (typeof expectedPassedTests === "undefined") { + if (expectedPassedTests === undefined) { 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"); } @@ -274,11 +257,11 @@ Run worker process for given permissions: OPTIONS: - --master + --master Run in master mode, spawning worker processes for each discovered permission combination - - --worker + + --worker Run in worker mode, requires "perms" and "addr" flags, should be run with "-A" flag; after setup worker will drop permissions to required set specified in "perms" @@ -290,7 +273,7 @@ OPTIONS: Address of TCP socket for reporting ARGS: - -- ... + -- ... Run only tests with names matching filter, must be used after "--" `;