UNPKG

@stryker-mutator/core

Version:

The extendable JavaScript mutation testing framework

45 lines 2.14 kB
import { URL } from 'url'; import { ExpirableTask } from '@stryker-mutator/util'; import { ChildProcessCrashedError } from '../child-proxy/child-process-crashed-error.js'; import { ChildProcessProxy } from '../child-proxy/child-process-proxy.js'; import { ChildProcessTestRunnerWorker } from './child-process-test-runner-worker.js'; const MAX_WAIT_FOR_DISPOSE = 2000; /** * Runs the given test runner in a child process and forwards reports about test results */ export class ChildProcessTestRunnerProxy { worker; log; constructor(options, fileDescriptions, sandboxWorkingDirectory, loggingServerAddress, pluginModulePaths, getLogger, idGenerator) { this.log = getLogger(ChildProcessTestRunnerProxy.name); this.worker = ChildProcessProxy.create(new URL('./child-process-test-runner-worker.js', import.meta.url).toString(), loggingServerAddress, options, fileDescriptions, pluginModulePaths, sandboxWorkingDirectory, ChildProcessTestRunnerWorker, options.testRunnerNodeArgs, getLogger, idGenerator); } capabilities() { return this.worker.proxy.capabilities(); } init() { return this.worker.proxy.init(); } dryRun(options) { return this.worker.proxy.dryRun(options); } mutantRun(options) { return this.worker.proxy.mutantRun(options); } async dispose() { await ExpirableTask.timeout( // First let the inner test runner dispose this.worker.proxy.dispose().catch((error) => { // It's OK if the child process is already down. if (!(error instanceof ChildProcessCrashedError)) { // Handle error by logging it. We still want to kill the child process. this.log.warn('An unexpected error occurred during test runner disposal. This might be worth looking into. Stryker will ignore this error.', error); } }), // ... but don't wait forever on that MAX_WAIT_FOR_DISPOSE); // After that, dispose the child process itself await this.worker.dispose(); } } //# sourceMappingURL=child-process-test-runner-proxy.js.map