UNPKG

1.7 kBPlain TextView Raw
1import { URL } from 'url';
2
3import { FileDescriptions, Mutant, StrykerOptions } from '@stryker-mutator/api/core';
4import { Disposable } from 'typed-inject';
5
6import { ChildProcessProxy } from '../child-proxy/child-process-proxy.js';
7import { LoggingClientContext } from '../logging/index.js';
8import { Resource } from '../concurrent/pool.js';
9import { IdGenerator } from '../child-proxy/id-generator.js';
10
11import { CheckerWorker } from './checker-worker.js';
12import { CheckerResource } from './checker-resource.js';
13
14export class CheckerChildProcessProxy implements CheckerResource, Disposable, Resource {
15 private readonly childProcess: ChildProcessProxy<CheckerWorker>;
16
17 constructor(
18 options: StrykerOptions,
19 fileDescriptions: FileDescriptions,
20 pluginModulePaths: readonly string[],
21 loggingContext: LoggingClientContext,
22 idGenerator: IdGenerator
23 ) {
24 this.childProcess = ChildProcessProxy.create(
25 new URL('./checker-worker.js', import.meta.url).toString(),
26 loggingContext,
27 options,
28 fileDescriptions,
29 pluginModulePaths,
30 process.cwd(),
31 CheckerWorker,
32 options.checkerNodeArgs,
33 idGenerator
34 );
35 }
36
37 public async dispose(): Promise<void> {
38 await this.childProcess.dispose();
39 }
40
41 public async init(): Promise<void> {
42 await this.childProcess.proxy.init();
43 }
44
45 public async check(checkerName: string, mutants: Mutant[]): ReturnType<CheckerResource['check']> {
46 return this.childProcess.proxy.check(checkerName, mutants);
47 }
48
49 public async group(checkerName: string, mutants: Mutant[]): ReturnType<CheckerResource['group']> {
50 return this.childProcess.proxy.group(checkerName, mutants);
51 }
52}