infection / infection

PHP Mutation Testing library
https://infection.github.io
BSD 3-Clause "New" or "Revised" License
2.05k stars 160 forks source link

Directories glob patterns broken when used with --git-diff-filter #1714

Open ndench opened 2 years ago

ndench commented 2 years ago
Question Answer
Infection version 0.26.13
Test Framework version PHPUnit 9.5.21
PHP version 8.1.18
Platform Debian (docker)
Github Repo -

We run infection only over a specific subset of the codebase which contains heavy business logic. This allows us to enforce a 100% MSI for critical code paths. We do this by using file glob patterns in the directories config section, eg. src/*/Core.

This was recently broken by #1697, specifically by adding the directories configuration to git diff command with escapeshellarg which results in the git diff command being changed to the following, which returns an empty list of changes.

git diff <commit sha> --diff-filter=AM --name-only --  'src/*/Core'

Is there any reason that we need escapeshellarg here? That's usually used to prevent untrusted data being executed, but it should only ever include data provided by the same user who is running the command right?

Alternatively, maybe the directories config property could support regex like excludes does?

phpunit.xml ```xml ./src/ tests/ tests/Unit/ tests/Integration/ tests/Message/ tests/Contract/ tests/Model tests/Task tests/Functional/ ```
infection.json.dist ```json { "timeout": 30, "source": { "directories": [ "src/Security", "src/*/Core", "src/*/Action", "src/Integrations/*/Action", "src/Integrations/*/Core", "src/*/Enum", ], "excludes": [ "Migrations" ] }, "testFrameworkOptions": "--testsuite=Unit", "mutators": { "@default": true, "IdenticalEqual" : false, "NotIdenticalNotEqual": false, "MBString": false }, "logs": { "text": "build\/infection\/log.txt", "debug": "build\/infection\/debug.txt", "summary": "build\/infection\/summary.txt" } } ```
Output with issue ``` [OK] No files in diff found, skipping mutation analysis. ```
aurum86 commented 6 months ago

Having the same issue on similar scenario.

maks-rafalko commented 6 months ago

@aurum86 could you please provide details about your case? What is the infection.json5, how do you run infection (command line)?

I can't reproduce it. Mention escapeshellarg has been removed a while ago, so probably @aurum86 you have different issue