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

feat(in place): support in-place mutation #2706

Merged
merged 23 commits into from Jan 22, 2021
Merged

feat(in place): support in-place mutation #2706

merged 23 commits into from Jan 22, 2021

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Jan 21, 2021

Add --inPlace flag (or equivalent in stryker.conf.json file). When inPlace is true (default is false), mutations are written "in place", overriding the user's own files. This way, Stryker can support more exotic project configurations, where even copying to a temp directory breaks the test run. For example, when a project relies on app-root-path or uses the NODE_PATH environment variable.

Support for --inPlace added in the Sandbox class. For each file that changes, it writes a backup to a ".stryker-tmp/backup123" directory. After mutation testing completes, the backup files are recovered from the backup directory.

Stryker tries its best to recover the backup files and when the process exits unexpectantly, for example, using CTRL+C or by closing the window. This behavior is a best-effort since Stryker can't do anything for you when you kill it from the task manager or with kill -9.

Fixes #2163

Todo:

  • Add unit tests for unexpected-exit-handler.ts
  • Update unit tests for stryker.ts
  • Update unit tests for sandbox.ts
  • Add integration test for moveDirectoryRecursiveSync
  • Verify that all e2e tests run with inPlace mode active.
  • Don't use system temp dir, instead use .stryker-tmp.
  • Refactor stryker-registry to use constructor and dispose

Add `--inPlace` flag. When `inPlace` mode is active, mutations will be written in-place, overriding any local changes.
@nicojs nicojs marked this pull request as draft January 21, 2021 15:42
@nicojs nicojs marked this pull request as ready for review January 22, 2021 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to mutate files in place
1 participant