1 | import { TestRunner } from '@stryker-mutator/api/test-runner';
|
2 | import { FileDescriptions, StrykerOptions } from '@stryker-mutator/api/core';
|
3 | import { tokens, commonTokens } from '@stryker-mutator/api/plugin';
|
4 | import { LoggerFactoryMethod } from '@stryker-mutator/api/logging';
|
5 |
|
6 | import { LoggingClientContext } from '../logging/index.js';
|
7 | import { coreTokens } from '../di/index.js';
|
8 | import { Sandbox } from '../sandbox/sandbox.js';
|
9 |
|
10 | import { IdGenerator } from '../child-proxy/id-generator.js';
|
11 |
|
12 | import { RetryRejectedDecorator } from './retry-rejected-decorator.js';
|
13 | import { TimeoutDecorator } from './timeout-decorator.js';
|
14 | import { ChildProcessTestRunnerProxy } from './child-process-test-runner-proxy.js';
|
15 | import { CommandTestRunner } from './command-test-runner.js';
|
16 | import { MaxTestRunnerReuseDecorator } from './max-test-runner-reuse-decorator.js';
|
17 | import { ReloadEnvironmentDecorator } from './reload-environment-decorator.js';
|
18 |
|
19 | createTestRunnerFactory.inject = tokens(
|
20 | commonTokens.options,
|
21 | commonTokens.fileDescriptions,
|
22 | coreTokens.sandbox,
|
23 | coreTokens.loggingContext,
|
24 | commonTokens.getLogger,
|
25 | coreTokens.pluginModulePaths,
|
26 | coreTokens.workerIdGenerator
|
27 | );
|
28 | export function createTestRunnerFactory(
|
29 | options: StrykerOptions,
|
30 | fileDescriptions: FileDescriptions,
|
31 | sandbox: Pick<Sandbox, 'workingDirectory'>,
|
32 | loggingContext: LoggingClientContext,
|
33 | getLogger: LoggerFactoryMethod,
|
34 | pluginModulePaths: readonly string[],
|
35 | idGenerator: IdGenerator
|
36 | ): () => TestRunner {
|
37 | if (CommandTestRunner.is(options.testRunner)) {
|
38 | return () => new RetryRejectedDecorator(() => new TimeoutDecorator(() => new CommandTestRunner(sandbox.workingDirectory, options)));
|
39 | } else {
|
40 | return () =>
|
41 | new RetryRejectedDecorator(
|
42 | () =>
|
43 | new ReloadEnvironmentDecorator(
|
44 | () =>
|
45 | new MaxTestRunnerReuseDecorator(
|
46 | () =>
|
47 | new TimeoutDecorator(
|
48 | () =>
|
49 | new ChildProcessTestRunnerProxy(
|
50 | options,
|
51 | fileDescriptions,
|
52 | sandbox.workingDirectory,
|
53 | loggingContext,
|
54 | pluginModulePaths,
|
55 | getLogger(ChildProcessTestRunnerProxy.name),
|
56 | idGenerator
|
57 | )
|
58 | ),
|
59 | options
|
60 | )
|
61 | )
|
62 | );
|
63 | }
|
64 | }
|