1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -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 // 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;
for await (const line of readLines(conn)) { try {
const msg = JSON.parse(line); for await (const line of readLines(conn)) {
const msg = JSON.parse(line);
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; continue;
} else if (msg.kind === Deno.TestEvent.TestStart) { } else if (msg.kind === Deno.TestEvent.TestStart) {
await reporter.testStart(msg); await reporter.testStart(msg);
continue; continue;
} else if (msg.kind === Deno.TestEvent.TestEnd) { } else if (msg.kind === Deno.TestEvent.TestEnd) {
await reporter.testEnd(msg); await reporter.testEnd(msg);
continue; continue;
} else { } else {
endEvent = msg; endEvent = msg;
await reporter.end(msg); await reporter.end(msg);
break; break;
}
} }
} catch (e) {
err = e;
} finally {
// Close socket to worker, it should shutdown gracefully.
conn.close();
} }
// Close socket to worker, it should shutdown gracefully. if (err) {
conn.close(); if (err instanceof Deno.errors.ConnectionReset) {
if (!endEvent) {
throw err;
}
} else {
throw err;
}
}
if (typeof expectedPassedTests === "undefined") { if (typeof expectedPassedTests === "undefined") {
throw new Error("Worker runner didn't report start"); throw new Error("Worker runner didn't report start");

View file

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