-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Protect compiler directives during mutation #3116
Conversation
…_directives # Conflicts: # src/Stryker.Core/Stryker.Core.UnitTest/Mutants/CsharpMutantOrchestratorTests.cs
…es (and revert them on roll back
…ssionmutator and replace it with two extra mutators, add semancticinfo to unit tests
c6e5ac8
to
6826228
Compare
f34711e
to
e9ba29d
Compare
e9ba29d
to
bfec606
Compare
c3017ec
to
80871b8
Compare
I am happy to see this PR reduces the total number of lines, and it increases the number of mutations. This is probably related to the redesign of the pattern mutator that I modified so it no longer does some internal scan and reenabled orchestration of patterns in general |
4102df8
to
f5bbfd9
Compare
f5bbfd9
to
df53cc3
Compare
…_directives # Conflicts: # integrationtest/Validation/ValidationProject/ValidateStrykerResults.cs
…into improve_mutation_of_directives
integrationtest/TargetProjects/NetCore/EmptyTestProject/Main.cs
Outdated
Show resolved
Hide resolved
…_directives # Conflicts: # integrationtest/Validation/ValidationProject/ValidateStrykerResults.cs
01a58fe
to
60a7a04
Compare
6fad9f2
to
ba24808
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR, @dupdob ! It's looking pretty good.
One more question, just to verify my understanding: now, all mutators should remove almost all trivia, including directives. Then, the InstrumentationEngines re-add the removed trivia, correct?
Is this process designed like this to make sure that the trivia is only added once (to prevent duplicate directive trivia, for example)?
src/Stryker.Core/Stryker.Core.UnitTest/Mutators/IsPatternExpressionMutatorTests.cs
Outdated
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core.UnitTest/Mutators/IsPatternExpressionMutatorTests.cs
Outdated
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core.UnitTest/Mutators/StringMethodMutatorTests.cs
Outdated
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core.UnitTest/Mutators/StringMethodMutatorTests.cs
Outdated
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core/Mutators/NullCoalescingExpressionMutator.cs
Outdated
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core/Instrumentation/ConditionalInstrumentationEngine.cs
Show resolved
Hide resolved
src/Stryker.Core/Stryker.Core/Instrumentation/IfInstrumentationEngine.cs
Show resolved
Hide resolved
@Liam-Rougoor: short answer is yes. |
Quality Gate passedIssues Measures |
@richardwerkman and @rouke-broersma : an important point I forgot to raise explicitly: as per @Liam-Rougoor remarks, with this PR, mutators are no longer allowed to arbitrarily mutates sub nodes. Impacted mutators (mainly Pattern related mutators) have been modified accordingly. It turns out this behavior was induced Stryker not properly walking pattern syntax nodes, forcing the mutators to do this on their own. Stryker now walks theses nodes properly. As such, these mutators no longer need to perform discovery on their own. This requirement allows the general orchestration to modify the original node before it being submitted for mutation, such as stripping unnecessary trivia. |
Sounds like a good improvement, we will need to be vigilant to keep this in place. |
sub node mutation fails currently, as in the mutation will fail to be injected and will raise an exception, alerting the developer he/she is violating something. I tried for days to clean trivia beforehand, but I failed to achieve a correct orchestration while doing it, so I reverted my strategy (as presented in the slack, IIRC), but kept what I feel like a cleaner design, due to the separation of concerns between orchestration and mutation |
I don't see any reason to try to reverse this decision unless we notice that it causes other problems, as I agree that the clearer separation sounds like a good direction 👌. |
Ensure compiler directives (#if, #pragma....) are not mutated but kept around mutated syntax nodes.
This required small changes in every mutator, as they are not responsible for removing any directive.
I took this as an opportunity to improve the design.
Also, added generation of semantic model during mutation tests to ensure mutator related unit tests are relevant.
I may have fixed some minor issues on them.
Also added some top level statement in integration test as it was a quick win
FIxes #3081, #3102