Skip to content

Abort tests when test runner script is aborted #3627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions scripts/emulator-testing/firestore-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
*/

// @ts-ignore
import { spawn } from 'child-process-promise';
import {
spawn,
ChildProcessPromise,
SpawnPromiseResult
} from 'child-process-promise';
import * as path from 'path';
// @ts-ignore
import * as freePortFinder from 'find-free-port';
Expand All @@ -35,19 +39,32 @@ function runTest(port: number, projectId: string, withPersistence: boolean) {
// TODO(b/113267261): Include browser test once WebChannel support is
// ready in Firestore emulator.
// Use `prod` to allow test runner's env variable overrides to work.
const childProcesses: ChildProcessPromise<SpawnPromiseResult>[] = [];
if (withPersistence) {
return Promise.all([
childProcesses.push(
spawn('yarn', ['test:node:persistence:prod'], options),
spawn('yarn', ['test:exp:persistence:prod'], options),
spawn('yarn', ['test:lite:prod'], options)
]);
);
} else {
return Promise.all([
childProcesses.push(
spawn('yarn', ['test:node:prod'], options),
spawn('yarn', ['test:exp:prod'], options),
spawn('yarn', ['test:lite:prod'], options)
]);
);
}

process.once('exit', () =>
childProcesses.forEach(p => p.childProcess.kill())
);
process.once('SIGINT', () =>
childProcesses.forEach(p => p.childProcess.kill('SIGINT'))
);
process.once('SIGTERM', () =>
childProcesses.forEach(p => p.childProcess.kill('SIGTERM'))
);

return Promise.all(childProcesses);
}

async function run(): Promise<void> {
Expand Down