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

Gradle test task fails when run test with intellij coverage and kover plugin enabled #7

Closed
Corje opened this issue Sep 14, 2021 · 8 comments
Labels
Bug Bug issue type S: postponed Status: work on the issue is not in the short term plans

Comments

@Corje
Copy link

Corje commented Sep 14, 2021

Enable kover plugin in build script.
Try to run any test with coverage. Test should be run via gradle - Preferences | Build, Execution, Deployment | Build Tools | Gradle | Run tests using Gradle. Right click on run gutter near a test and select Run test .. with coverage
Test task is failed with:

Error: LinkageError occurred while loading main class worker.org.gradle.process.internal.worker.GradleWorkerMain
	java.lang.ClassFormatError: Duplicate field name "__$lineHits$__" with signature "[I" in class file worker/org/gradle/process/internal/worker/GradleWorkerMain
Class transformation time: 0.00528344s for 211 classes or 2.504E-5s per class
Class transformation time: 0.026119615s for 136 classes or 1.9205599264705882E-4s per class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 45' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Disabling kover-plugin solves the problem. Also with setting Preferences | Build, Execution, Deployment | Build Tools | Gradle | Run tests using Intellij IDEA run test with coverage is ok.

Reproduced with: 'org.jetbrains.kover-plugin' version '0.4', intellij-coverage-agent-1.0.596.jar, Kotlin JVM Gradle plugin 1.6.0-RC-303, gradle-7.1

@Corje
Copy link
Author

Corje commented Sep 28, 2021

In kotlinx-kover 0.2.2 it fails with different reported errors:

...
---- IntelliJ IDEA coverage runner ---- 
tracing ...
include patterns:
exclude patterns:
[2021.09.28 16:55:03] (Coverage): Error during class instrumentation: com/intellij/rt/coverage/util/ClassNameUtil: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
Exception in thread "main" java.lang.NullPointerException
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:76)
[2021.09.28 16:55:04] (Coverage): Unexpected error during applying branch data to class worker.org.gradle.internal.classloader.FilteringClassLoader: java.lang.NullPointerException
Class transformation time: 0.024064203s for 133 classes or 1.8093385714285714E-4s per class
Class transformation time: 0.018251085s for 177 classes or 1.0311347457627118E-4s per class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Process 'Gradle Test Executor 6' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 601ms
3 actionable tasks: 1 executed, 2 up-to-date

@mhmtszr
Copy link

mhmtszr commented Jan 4, 2022

We have the same issue.

@gustavodaquino
Copy link

Same here, with 0.5.0-RC2 version.

---- IntelliJ IDEA coverage runner ---- 
tracing ...
include patterns:
exclude patterns:
[2022.01.28 00:32:10] (Coverage): Error during class instrumentation: com/intellij/rt/coverage/util/ClassNameUtil: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException

	at org.jacoco.agent.rt.internal_3570298.PreMain.premain(PreMain.java:48)
	... 6 more
FATAL ERROR in native method: processing of -javaagent failed, processJavaStart failed
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at ./src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422

@elmodeer
Copy link

I am facing this issue now. But I got it solved by changing the kotlinx.kover.api.CoverageEngine type from IntelliJ to Jacoco, although I am using IntelliJ

@mskonovalov
Copy link

Similar issue here
I can see a bunch of errors like

[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: com/intellij/rt/coverage/util/ClassNameUtil: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: sun/launcher/LauncherHelper: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: sun/launcher/LauncherHelper: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$3: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$3: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$Loader: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$Loader: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$JarLoader: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/loader/URLClassPath$JarLoader: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/access/JavaUtilZipFileAccess: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
[2022.05.16 14:43:57] (Coverage): Error during class instrumentation: jdk/internal/access/JavaUtilZipFileAccess: java.lang.ClassCircularityError: com/intellij/rt/coverage/util/ClassNameUtil
...

and test is taking forever to start (on JDK 17).
Any hints?

@mskonovalov
Copy link

It could be on the Intellij side https://youtrack.jetbrains.com/issue/IDEA-283432

@Zyphuris55
Copy link

For those still with this issue, please see the comment I made here as a workaround.
#138 (comment)

@shanshin shanshin added Bug Bug issue type S: postponed Status: work on the issue is not in the short term plans and removed wontfix Kover Gradle Plugin labels Oct 14, 2022
@shanshin
Copy link
Collaborator

Duplicates #267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug issue type S: postponed Status: work on the issue is not in the short term plans
Projects
None yet
Development

No branches or pull requests

7 participants