Skip to content
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

Kotlin Generated Code Mutation Survival #569

Closed
SkittishSloth opened this issue Feb 15, 2019 · 5 comments
Closed

Kotlin Generated Code Mutation Survival #569

SkittishSloth opened this issue Feb 15, 2019 · 5 comments

Comments

@SkittishSloth
Copy link

When running against kotlin code, I'm getting a lot of false survivals of removed call to kotlin/jvm/internal/Intrinsics::checkExpressionValueIsNotNull → SURVIVED. I'm assuming this is code that's generated by the kotlin compiler for non-nullable types; I'm seeing it in lots of places, and I'm definitely not calling it anywhere directly.

Kinda related, on an interpolated String (i.e. "Hello $name"), I'm getting a removed call to java/lang/StringBuilder::toString → SURVIVED. I'm early in writing tests for this project, so this might go away when I've actually written coverage for it, but it's a little confusing at first. Not as big a problem as the null check.

If I add the Intrinsics class to the avoidCallsTo configuration, both of these goes away BUT I lose a lot of other potentially useful mutations too. (And the StringBuilder one is pretty useful too, assuming it kills when I've added the appropriate tests.) I've tried explicitly adding the method to avoidCalls, tried adding it to excludedMethods, no joy. I didn't expect adding it to avoidCalls to work, I believe that's class level, and I might've been using some wrong syntax for excludedMethods.

Any ideas?

@hcoles
Copy link
Owner

hcoles commented Feb 15, 2019

The fix for this would be the kotlin plugin

https://github.com/pitest/pitest-kotlin

However it is looking for someone to develop and maintain it.

@SkittishSloth
Copy link
Author

SkittishSloth commented Feb 15, 2019 via email

@JoaoGFarias
Copy link

@hcoles Any hope to it be published, even without active maintenance? pitest/pitest-kotlin#3

@z5y
Copy link

z5y commented Sep 27, 2020

I solved the problem by using avoidCallsTo in the configuration. I use maven in this project, but something similar can be done with gradle as well:

 <plugin>
        <groupId>org.pitest</groupId>
        <artifactId>pitest-maven</artifactId>
        <version>1.5.2</version>
        <dependencies>
          <dependency>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-junit5-plugin</artifactId>
            <version>0.12</version>
          </dependency>
        </dependencies>
        <configuration>
          <!-- targetClass and targetTests here -->
          <avoidCallsTo>
            <avoidCallsTo>kotlin.jvm.internal</avoidCallsTo>
            <avoidCallsTo>kotlinx.coroutines</avoidCallsTo>
          </avoidCallsTo>
        </configuration>
      </plugin>

cwoolner added a commit to cwoolner/flex-poker that referenced this issue Dec 28, 2020
@hcoles
Copy link
Owner

hcoles commented Apr 2, 2024

Kotlin support is now available at https://docs.arcmutate.com/docs/kotlin.html

@hcoles hcoles closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants