Add new --git-diff-lines
option to generate Mutants only for the changed *lines*
#1632
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've posted a question recently in twitter (https://twitter.com/infection_php/status/1475841561695072259) asking what is the most wanted feature needed in Infection for developers.
One of the interesting feature request was to mutate only changed/added lines (note: currently in
master
as a minimum, we can mutate only added/changed files by--git-diff-filter=AM
)So, here is an implementation of the new option -
--git-diff-lines
that parsersgit diff
output, finds changed/added lines and filters out all mutants that are not for these lines.This option automatically mutates only Added and Modified files (
--git-diff-filter=AM
under the hood).Useful to check how your changes impacts MSI in a feature branch. Useful for those who do not want / can't write tests for the whole legacy file, but wants to cover their own changes.
@Ocramius - this is your feature request, if you have some time, please help us testing on one of your projects. I've prepared a PHAR for this PR:
infection.phar.zip
How to use (as an example):
by default it does a diff with
master
branch, but this can be changed: