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

Support testing with coverage in dev mode #1199

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

Bencodes
Copy link
Collaborator

@Bencodes Bencodes commented Jul 17, 2024

Mirrors the release behavior by adding the jacoco instrumentation library to the worker runtime dependencies so that coverage works locally while iterating against rules_kotlin directly.

java.lang.NoClassDefFoundError: org/jacoco/core/instr/Instrumenter
        at io.bazel.kotlin.builder.tasks.jvm.JacocoInstrumentationKt.createCoverageInstrumentedJar(JacocoInstrumentation.kt:19)
        at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor$execute$1$1$6.invoke(KotlinJvmTaskExecutor.kt:112)
        at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor$execute$1$1$6.invoke(KotlinJvmTaskExecutor.kt:112)
        at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:153)
        at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:145)
        at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor$execute$1.invoke(KotlinJvmTaskExecutor.kt:112)
        at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor$execute$1.invoke(KotlinJvmTaskExecutor.kt:54)
        at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:153)
        at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:145)
        at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor.execute(KotlinJvmTaskExecutor.kt:54)
        at io.bazel.kotlin.builder.tasks.KotlinBuilder.executeJvmTask(KotlinBuilder.kt:211)
        at io.bazel.kotlin.builder.tasks.KotlinBuilder.build(KotlinBuilder.kt:104)
        at io.bazel.kotlin.builder.tasks.CompileKotlin.invoke(CompileKotlin.kt:27)
        at io.bazel.worker.PersistentWorker$workTo$1.invoke(PersistentWorker.kt:97)
        at io.bazel.worker.PersistentWorker$workTo$1.invoke(PersistentWorker.kt:97)
        at io.bazel.worker.WorkerContext$TaskContext.resultOf(WorkerContext.kt:128)
        at io.bazel.worker.WorkerContext.doTask(WorkerContext.kt:156)
        at io.bazel.worker.PersistentWorker$start$1$1$producer$1$1$1.call(PersistentWorker.kt:70)
        at io.bazel.worker.PersistentWorker$start$1$1$producer$1$1$1.call(PersistentWorker.kt:69)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.jacoco.core.instr.Instrumenter
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        ... 25 more

@@ -57,7 +57,7 @@ def kt_bootstrap_library(name, deps = [], neverlink_deps = [], srcs = [], visibi
def kt_bootstrap_binary(
name,
main_class,
runtime_library,
runtime_deps,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this to align better with what java_binary and the rest of the java rules use.

shade_rules = "//src/main/kotlin:shade.jarjar",
visibility = ["//src:__subpackages__"],
runtime_deps = [
":build_lib",
"@bazel_tools//tools/jdk:JacocoCoverage",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix. The BUILD.bazel version of this file has this included as a runtime dependency already.

@Bencodes Bencodes merged commit f14d01e into master Jul 17, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants