1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const typed_inject_1 = require("typed-inject");
|
4 | const plugin_1 = require("@stryker-mutator/api/plugin");
|
5 | const logging_1 = require("./logging");
|
6 | const process_1 = require("./process");
|
7 | const di_1 = require("./di");
|
8 | const errors_1 = require("./errors");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | class Stryker {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | constructor(cliOptions, injectorFactory = typed_inject_1.createInjector) {
|
20 | this.cliOptions = cliOptions;
|
21 | this.injectorFactory = injectorFactory;
|
22 | }
|
23 | async runMutationTest() {
|
24 | const rootInjector = this.injectorFactory();
|
25 | const loggerProvider = di_1.provideLogger(rootInjector);
|
26 | try {
|
27 |
|
28 | const prepareExecutor = loggerProvider.provideValue(di_1.coreTokens.cliOptions, this.cliOptions).injectClass(process_1.PrepareExecutor);
|
29 | const mutantInstrumenterInjector = await prepareExecutor.execute();
|
30 | try {
|
31 |
|
32 | const mutantInstrumenter = mutantInstrumenterInjector.injectClass(process_1.MutantInstrumenterExecutor);
|
33 | const dryRunExecutorInjector = await mutantInstrumenter.execute();
|
34 |
|
35 | const dryRunExecutor = dryRunExecutorInjector.injectClass(process_1.DryRunExecutor);
|
36 | const mutationRunExecutorInjector = await dryRunExecutor.execute();
|
37 |
|
38 | const mutationRunExecutor = mutationRunExecutorInjector.injectClass(process_1.MutationTestExecutor);
|
39 | const mutantResults = await mutationRunExecutor.execute();
|
40 | return mutantResults;
|
41 | }
|
42 | catch (error) {
|
43 | const log = loggerProvider.resolve(plugin_1.commonTokens.getLogger)(Stryker.name);
|
44 | log.debug('Not removing the temp dir because an error occurred');
|
45 | mutantInstrumenterInjector.resolve(di_1.coreTokens.temporaryDirectory).removeDuringDisposal = false;
|
46 | throw error;
|
47 | }
|
48 | }
|
49 | catch (error) {
|
50 | const log = loggerProvider.resolve(plugin_1.commonTokens.getLogger)(Stryker.name);
|
51 | const cause = errors_1.retrieveCause(error);
|
52 | if (cause instanceof errors_1.ConfigError) {
|
53 | log.error(cause.message);
|
54 | }
|
55 | else {
|
56 | log.error(error);
|
57 | if (!log.isTraceEnabled()) {
|
58 | log.info('Trouble figuring out what went wrong? Try `npx stryker run --fileLogLevel trace --logLevel debug` to get some more info.');
|
59 | }
|
60 | }
|
61 | throw cause;
|
62 | }
|
63 | finally {
|
64 | await rootInjector.dispose();
|
65 | await logging_1.LogConfigurator.shutdown();
|
66 | }
|
67 | }
|
68 | }
|
69 | exports.default = Stryker;
|
70 |
|
\ | No newline at end of file |