stryker-mutator / stryker-net

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

fix: Conditional access mutations could lead to unrecoverable NullReferenceException in compilation #2888

Closed dupdob closed 3 months ago

dupdob commented 3 months ago

Fix issues related to Conditional Access (and NullSuppression operator) Add recovery mechanism for when the compilation triggers null reference exception

Fix #2880

richardwerkman commented 3 months ago

I've tested this and it seems to work :)

But I'm still seeing some error logging:

[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.
[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.
[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.
[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..
[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..

When was this added? And should we fix these in this PR? Or can we fix this later

dupdob commented 3 months ago

Thanks for reporting.

I've tested this and it seems to work :)

But I'm still seeing some error logging:

[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.
[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.
[17:23:35 ERR] Some mutations failed to be inserted, they are dropped.

This is not new, there was several way for mutations to be silently loss along the way. My last refactoring made the process more trustworthy. That being said, this should not be reported as an error. I fill fix that.

[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..
[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..

I think I added this in my refactor PR while analyzing some strange issues. At first I assumed there was a problem copying the mutated assembly, but it turned out to be that Stryker was running unrelated test

Will fix in this PR

dupdob commented 3 months ago

Continuing comment:

[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..
[17:24:53 ERR] VsTestRunner: Coverage collector error: Did not find type StrykerH7r178e2ZZDsDvd.MutantControl. This indicates Stryker failed to copy the mutated assembly for test..

So these are triggered by the mutated assembly not being tested by any test. It can happen with solution mode due to the support for transitive testing. In Stryker's case, these are triggered by Stryker.RegexMutators. This messages could also be triggered by the mutated assembly failing to copy for some reason

==> I downgraded severity down to Debug and stressed the lack of testing as the probable cause

dupdob commented 3 months ago

@richardwerkman : it should be ok now, could please check it again and confirm on your side?

sonarcloud[bot] commented 3 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
51.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

richardwerkman commented 3 months ago

@dupdob thanks for the quick fix! Great work 👍

dupdob commented 3 months ago

your feedback is welcomed 😄