You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Until now, a Injector does not store references to its child instances. We might want to add support for that in order to support more complex scenario's where you would want to dispose the entire dependency injection tree all at once.
An example from the Stryker source code:
letmutantInstrumenterInjector: Injector<MutantInstrumenterContext>|undefined;letdryRunExecutorInjector: Injector<DryRunContext>|undefined;letmutationRunExecutorInjector: Injector<MutationTestContext>|undefined;try{// 1. Prepare. Load Stryker configuration, load the input files and starts the logging serverconstprepareExecutor=this.injector.provideValue(coreTokens.cliOptions,this.cliOptions).injectClass(PrepareExecutor);mutantInstrumenterInjector=awaitprepareExecutor.execute();// 2. Mutate and instrument the files and write to the sandbox.constmutantInstrumenter=mutantInstrumenterInjector.injectClass(MutantInstrumenterExecutor);dryRunExecutorInjector=awaitmutantInstrumenter.execute();// 3. Perform a 'dry run' (initial test run). Runs the tests without active mutants and collects coverage.constdryRunExecutor=dryRunExecutorInjector.injectClass(DryRunExecutor);mutationRunExecutorInjector=awaitdryRunExecutor.execute();// 4. Actual mutation testing. Will check every mutant and if valid run it in an available test runner.constmutationRunExecutor=mutationRunExecutorInjector.injectClass(MutationTestExecutor);constmutantResults=awaitmutationRunExecutor.execute();returnmutantResults;}finally{if(mutationRunExecutorInjector){awaitmutationRunExecutorInjector.dispose();}elseif(dryRunExecutorInjector){awaitdryRunExecutorInjector.dispose();}elseif(mutantInstrumenterInjector){awaitmutantInstrumenterInjector.dispose();}}
We provide the Injector in each executor which builds upon it and returns it. In the finally clause, where we do clean up, we need the reference of the deepest child injector, since that would dispose of other injectors.
Suggestion:
constrootInjector=newRootInjector();try{// 1. Prepare. Load Stryker configuration, load the input files and starts the logging serverconstprepareExecutor=rootInjector.provideValue(coreTokens.cliOptions,this.cliOptions).injectClass(PrepareExecutor);constmutantInstrumenterInjector=awaitprepareExecutor.execute();// 2. Mutate and instrument the files and write to the sandbox.constmutantInstrumenter=mutantInstrumenterInjector.injectClass(MutantInstrumenterExecutor);constdryRunExecutorInjector=awaitmutantInstrumenter.execute();// 3. Perform a 'dry run' (initial test run). Runs the tests without active mutants and collects coverage.constdryRunExecutor=dryRunExecutorInjector.injectClass(DryRunExecutor);cosntmutationRunExecutorInjector=awaitdryRunExecutor.execute();// 4. Actual mutation testing. Will check every mutant and if valid run it in an available test runner.constmutationRunExecutor=mutationRunExecutorInjector.injectClass(MutationTestExecutor);constmutantResults=awaitmutationRunExecutor.execute();returnmutantResults;}finally{awaitrootInjector.dispose();}
The text was updated successfully, but these errors were encountered:
Until now, a
Injector
does not store references to its child instances. We might want to add support for that in order to support more complex scenario's where you would want todispose
the entire dependency injection tree all at once.An example from the Stryker source code:
We provide the
Injector
in each executor which builds upon it and returns it. In thefinally
clause, where we do clean up, we need the reference of thedeepest
child injector, since that would dispose of other injectors.Suggestion:
The text was updated successfully, but these errors were encountered: