stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.78k stars 185 forks source link

GitDiffProvider incorrectly classifies files #2072

Closed Aidenwasalreadytaken closed 2 years ago

Aidenwasalreadytaken commented 2 years ago

GitDiffProvider is incorrectly classifying source files as test files.

https://github.com/stryker-mutator/stryker-net/blob/46985134192ade92d5e56dc2ce45681ff92e41c9/src/Stryker.Core/Stryker.Core/DiffProviders/GitDiffProvider.cs#L55

If you're open to contributions, I can fix this issue up later today.

rouke-broersma commented 2 years ago

Of course we are open to contributions! Before you put in the effort to try and fix this, could you explain in which scenario you think this goes wrong so I can verify?

Aidenwasalreadytaken commented 2 years ago

Thanks Rouke,

The scenario is running dotnet dotnet-stryker --since:master from the source project directory. I have modified both test and source files. The modified source files are being logged as Changed test file and the modified test files as Changed file. All mutations are being ignored because of Mutant not changed compared to target commit

rouke-broersma commented 2 years ago

I see. It looks like this feature was built assuming running from the test project directory. This used to be the only way to run stryker. The correct fix would be to pass the MutationTestInput to the GitDiffProvider and to check whether a file exists in the source project or in one of the test projects.

rouke-broersma commented 2 years ago

Fixed by #2256