1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

try to handle ConnectionReset error in windows CI for unit tests (#4407)

This commit is contained in:
Bartek Iwańczuk 2020-03-17 22:35:38 +01:00 committed by GitHub
parent 9050d36d57
commit 4a4894532e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 18 deletions

View file

@ -127,31 +127,46 @@ async function runTestsForPermissionSet(
// Wait for worker subprocess to go online
const conn = await listener.accept();
let err: Error | undefined = undefined;
let expectedPassedTests;
let endEvent;
for await (const line of readLines(conn)) {
const msg = JSON.parse(line);
try {
for await (const line of readLines(conn)) {
const msg = JSON.parse(line);
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;
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.
conn.close();
}
// Close socket to worker, it should shutdown gracefully.
conn.close();
if (err) {
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");

View file

@ -275,6 +275,7 @@ fn js_unit_tests() {
.arg("-A")
.arg("cli/js/tests/unit_test_runner.ts")
.arg("--master")
.arg("--verbose")
.spawn()
.expect("failed to spawn script");
let status = deno.wait().expect("failed to wait for the child process");