Possible problem with Kotlin coroutines
See original GitHub issueI am getting this problem when running pitest in a project that uses Kotlin coroutines: https://gist.github.com/Octogonapus/6a14d814b107c0c78e74979f79e88718
I’m not sure what pitest is trying to accomplish here. arrow.typeclasses.ContinuationUtilsKt
appears frequently, could there be a problem related to custom coroutines? I think that pitest should stay out of dependency class files in general (arrow
is one of my dependencies).
This is my pitest configuration:
pitest {
testPlugin.set("junit5")
pitestVersion.set("1.4.10")
threads.set(4)
avoidCallsTo.set(setOf("kotlin.jvm.internal", "kotlinx.coroutines", "arrow"))
excludedMethods.set(
setOf(
"hashCode",
"equals",
"checkIndexOverflow",
"throwIndexOverflow",
"collectionSizeOrDefault"
)
)
excludedClasses.set(
setOf(
"NoSuchElementException",
"NoWhenBranchMatchedException",
"IllegalStateException"
)
)
timeoutConstInMillis.set(10000)
mutators.set(setOf("NEW_DEFAULTS"))
}
Pitest version: 1.4.10 Pitest Gradle plugin version: 1.4.5 Gradle version: 5.6.4 Kotlin version: 1.3.60 JVM version: 11.0.4+10-b520.11 amd64
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Introduction to Coroutines: What Problems Do They Solve?
A practical introduction on the new Kotlin feature: coroutines, which bring asynchronous programming to your favorite language.
Read more >Coroutines answer to the problem with the mutable state
It has one important danger: a coroutine cannot get past the lock twice (maybe the key stays in the door, so another door...
Read more >Concurrency and coroutines - Kotlin
It may be a problem if a mutable state is isolated in a single thread and coroutine threading operations are used for communication....
Read more >Bridging the gap between coroutines, threads, and ... - Medium
Maybe the class needs to keep the information of the logged-in user in memory, or cache some values while the app is alive....
Read more >Issues · Kotlin/kotlinx.coroutines - GitHub
Library support for Kotlin coroutines . Contribute to Kotlin/kotlinx.coroutines development by creating an account on GitHub.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this may be a bug in arrow.
This class looks to be trying to set values for all fields in a class, including the one pitest adds to hold the coverage probes.
https://github.com/arrow-kt/arrow/blob/master/modules/core/arrow-core-data/src/main/kotlin/arrow/typeclasses/ContinuationUtils.kt
The field pitest adds is marked as
I don’t know anything about arrow, but I think it highly likely that it shouldn’t be trying to touch fields with any one of those markers, and certainly not all three.
It looks to work with jacoco as jacoco doesn’t mark field it adds as final, so there is no error when it tries to set it. It still probably isn’t desirable behaviour however.
I could remove the final marker from the pit probe field, but this feels like the wrong thing todo, unless someone from arrow can explain why overwriting a synthetic final static field is desired.
If this is fixed in arrow there will likely still be issues with coroutines as pitest will probably produce a lot of junk mutations in the code the compiler generates unless some filters are added to remove them.
For anyone using pitest with kotlin coroutines, the arcmutate kotlin plugin now provides some support.