Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stryker 4.0 beta doesn't close when an error occurs #2315

Closed
nicojs opened this issue Jul 12, 2020 · 0 comments · Fixed by #2378
Closed

Stryker 4.0 beta doesn't close when an error occurs #2315

nicojs opened this issue Jul 12, 2020 · 0 comments · Fixed by #2378
Labels
🐛 Bug Something isn't working
Milestone

Comments

@nicojs
Copy link
Member

nicojs commented Jul 12, 2020

Summary

Stryker 4.0 beta doesn't close when an error occurs. Instead, it keeps hanging with the last line ERROR StrykerCli There were failed tests in the initial test run.. This happens because the injectors are not disposed of correctly.

We should either implement nicojs/typed-inject#24 and use rootInjector.dispose(), or implement this:

    let mutantInstrumenterInjector: Injector<MutantInstrumenterContext> | undefined;
    let dryRunExecutorInjector: Injector<DryRunContext> | undefined;
    let mutationRunExecutorInjector: Injector<MutationTestContext> | undefined;
    try {
      // 1. Prepare. Load Stryker configuration, load the input files and starts the logging server
      const prepareExecutor = this.injector.provideValue(coreTokens.cliOptions, this.cliOptions).injectClass(PrepareExecutor);
      mutantInstrumenterInjector = await prepareExecutor.execute();

      // 2. Mutate and instrument the files and write to the sandbox.
      const mutantInstrumenter = mutantInstrumenterInjector.injectClass(MutantInstrumenterExecutor);
      dryRunExecutorInjector = await mutantInstrumenter.execute();

      // 3. Perform a 'dry run' (initial test run). Runs the tests without active mutants and collects coverage.
      const dryRunExecutor = dryRunExecutorInjector.injectClass(DryRunExecutor);
      mutationRunExecutorInjector = await dryRunExecutor.execute();

      // 4. Actual mutation testing. Will check every mutant and if valid run it in an available test runner.
      const mutationRunExecutor = mutationRunExecutorInjector.injectClass(MutationTestExecutor);
      const mutantResults = await mutationRunExecutor.execute();
      return mutantResults;
    } finally {
      if (mutationRunExecutorInjector) {
        await mutationRunExecutorInjector.dispose();
      } else if (dryRunExecutorInjector) {
        await dryRunExecutorInjector.dispose();
      } else if (mutantInstrumenterInjector) {
        await mutantInstrumenterInjector.dispose();
      }
    }

However, this wouldn't be enough, because the DryRunExecutor currently creates its own test runner:

    const testRunnerInjector = this.injector
      // ...
      .provideFactory(coreTokens.testRunnerPool, createTestRunnerPool);
    const testRunnerPool = testRunnerInjector.resolve(coreTokens.testRunnerPool);

If something goes wrong during initial test run (dry run), the testRunnerInjector should also be disposed of correctly.

It might be better to implement nicojs/typed-inject#24 .

@nicojs nicojs added the 🐛 Bug Something isn't working label Jul 12, 2020
@nicojs nicojs added this to the 4.0 milestone Jul 12, 2020
nicojs added a commit that referenced this issue Aug 13, 2020
Exit with non-zero exit code when an error occurs. 

* Update typed-inject to v3 in order to dispose of the `rootInjector`
* Rename some e2e tests to better reflect what they're testing.
* Add an e2e test for a failing dry run. 

Fixes #2315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant