Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Performance] Add files to coverage whitelist instead of the whole di…
…rectories when `--filter` or `--git-diff-filter` are used (#1543) * Performance improvement: add files to coverage whitelist instead of the whole directories when `--filter` or `--git-diff-filter` are used Currently, when we build the initial tests `phpunit.xml` config, we add (if doesn't exist) the following coverage whitelist: ```xml <phpunit> <coverage> <include> <directory>src/</directory> <directory>example/</directory> </include> </coverage> </phpunit> ``` It means that **all** the files from directories `src/` and `example/` will be processed by coverage driver (be it `xdebug`, `pcov` or `phpdbg` ). Collecting code coverage costs a lot, that's why this change tries to reduce the number of files added to coverage whitelist, replacing `<directory>` tag with N `<file>` tags if possible. And one of the case is when we use `--filter=src/path/to/File1.php,src/path/to/File2.php` option, or when we use `--git-diff-filter=AM` option, that results internally to `--filter=X,Y,Z`. When the filter is used, we 100% know that we will mutate only particular files, so we need the code coverage only for them. Result initial `phpunit.xml` file will be like this: ``` infection --filter=src/path/to/File1.php,src/path/to/File2.php ``` ```xml <phpunit> <coverage> <include> <file>src/path/to/File1.php/</file> <file>src/path/to/File2.php/</file> </include> </coverage> </phpunit> ``` This will dramatically decrease the time needed for collecting coverage data since we reduce the number of processed files. * Use not-nullable array type for filtered source files to mutate * Use empty array instead of `null` as a default argument
- Loading branch information
1 parent
cfc3263
commit 193ab76
Showing
13 changed files
with
250 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.