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

Fix JaCoCo test report coverage #21

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Fix JaCoCo test report coverage #21

merged 2 commits into from
Mar 6, 2024

Conversation

twyatt
Copy link
Member

@twyatt twyatt commented Mar 5, 2024

Coverage was being reported as 0% because JaCoCo could not find .class files — when AtomicFU Gradle plugin is applied, the .class files are output to classes/atomicfu-orig directory instead of classes/kotlin.

Without AtomicFU Gradle plugin

Tested by making the following khronicle-core/build.gradle.kts changes:

  plugins {
      // ..
-     id("kotlinx-atomicfu")
  }
  
  kotlin {
      // ..
      sourceSets {
          // ..
          commonMain.dependencies {
+             implementation("org.jetbrains.kotlinx:atomicfu:0.23.1")
          }
      }
  }

Class files are where I traditionally have known them to be:

$ find . -type f -name '*.class'

..
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Log$WhenMappings.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Metadata.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Sensitivity$Companion.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/FilterLogger.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Log.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Sensitivity.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/ReadMetadata.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/LogKt$metadataPool$2.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$debug$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/FilterLevelLoggerKt.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/LogKt.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Logger.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/HideFromStackTraceTag.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$error$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$info$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/LogLevel.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/StackTraceTagGenerator.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/LogKt$metadataPool$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$assert$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/KhronicleInternal.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/WriteMetadata.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Key.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/ConstantTagGenerator.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Pool.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/TagGenerator.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/FilterLoggerKt.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLoggerKt.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatcherState$logLevel$2.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/CallListLogger.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatcherState.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/StackTraceTagGenerator$getTag$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/LogFilter.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Logger$DefaultImpls.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/ConsoleLogger.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$verbose$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/DispatchLogger$warn$1.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/Call.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/StackTraceTagGeneratorKt.class
./khronicle-core/build/classes/kotlin/jvm/main/com/juul/khronicle/FilterLevelLogger.class
..
With AtomicFU Gradle plugin

With the AtomicFU Gradle plugin applied, class files are relocated:

$ find . -type f -name '*.class'
..
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Log$WhenMappings.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Metadata.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Sensitivity$Companion.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/FilterLogger.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Log.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Sensitivity.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/ReadMetadata.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/LogKt$metadataPool$2.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Log$AtomicTagGeneratorRefVolatile.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$debug$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/FilterLevelLoggerKt.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/LogKt.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Logger.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/HideFromStackTraceTag.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$error$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$info$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/LogLevel.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/StackTraceTagGenerator.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/LogKt$metadataPool$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$assert$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/KhronicleInternal.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/WriteMetadata.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Key.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/ConstantTagGenerator.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Pool.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/TagGenerator.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/FilterLoggerKt.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLoggerKt.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatcherState$logLevel$2.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/CallListLogger.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatcherState.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/StackTraceTagGenerator$getTag$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/LogFilter.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Logger$DefaultImpls.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/ConsoleLogger.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$verbose$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/DispatchLogger$warn$1.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/Call.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/StackTraceTagGeneratorKt.class
./khronicle-core/build/classes/atomicfu/jvm/main/com/juul/khronicle/FilterLevelLogger.class
..
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Log$WhenMappings.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Metadata.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Sensitivity$Companion.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/FilterLogger.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Log.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Sensitivity.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/ReadMetadata.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/LogKt$metadataPool$2.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$debug$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/FilterLevelLoggerKt.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/LogKt.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Logger.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/HideFromStackTraceTag.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$error$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$info$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/LogLevel.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/StackTraceTagGenerator.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/LogKt$metadataPool$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$assert$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/KhronicleInternal.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/WriteMetadata.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Key.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/ConstantTagGenerator.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Pool.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/TagGenerator.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/FilterLoggerKt.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLoggerKt.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatcherState$logLevel$2.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/CallListLogger.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatcherState.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/StackTraceTagGenerator$getTag$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/LogFilter.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Logger$DefaultImpls.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/ConsoleLogger.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$verbose$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/DispatchLogger$warn$1.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/Call.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/StackTraceTagGeneratorKt.class
./khronicle-core/build/classes/atomicfu-orig/jvm/main/com/juul/khronicle/FilterLevelLogger.class

Using classes/atomicfu results in the following JaCoCo errors (and under reported coverage):

[ant:jacocoReport] Classes in bundle 'khronicle-core' do not match with execution data. For report generation the same class files must be used as at runtime.
[ant:jacocoReport] Execution data for class com/juul/khronicle/CallListLogger does not match.
[ant:jacocoReport] Execution data for class com/juul/khronicle/Log does not match.
[ant:jacocoReport] Execution data for class com/juul/khronicle/DispatchLogger does not match.
[ant:jacocoReport] Execution data for class com/juul/khronicle/Pool does not match.

While using classes/atmoicfu-orig properly reports coverage.

Coverage was being reported as 0% because JaCoCo could not find `.class`
files — when AtomicFU Gradle plugin is applied, the `.class` files are
output to `classes/atomicfu-orig` directory instead of `classes/kotlin`.
@twyatt twyatt added the maintenance General maintenance that doesn't effect the public API. label Mar 5, 2024
@twyatt twyatt requested review from cedrickcooke and a team as code owners March 5, 2024 19:17
@twyatt twyatt requested a review from Phoenix7351 March 5, 2024 19:17
@twyatt twyatt enabled auto-merge (squash) March 6, 2024 17:55
@twyatt twyatt merged commit 1ac897c into main Mar 6, 2024
2 checks passed
@twyatt twyatt deleted the twyatt/jacoco branch March 6, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance General maintenance that doesn't effect the public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants