Kotlin/kotlinx-kover

Configuration Cache can not be used after one run

remcomokveld opened this issue · 2 comments

Describe the bug

When the configuration cache is enabled, the cache entry is always immediately invalidated after the first run

Errors
If present, stacktraces or files from build/kover/errors directory

Expected behavior

After invoking a command once, the configuration cache from the previous invocation should be reused

Reproducer

By applying the following patch to the project you can see that the configuration cache is not used in the first identical run because the test assertion fails

Index: kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
--- a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(revision 8ca086b84546bdac370b81039ad4444022b276b8)
+++ b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(date 1719476509768)
@@ -29,6 +29,14 @@
             "koverVerify",
             "--configuration-cache",
         )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+            checker = { output.match { assertContains("Reusing configuration cache.") } }
+        )
     }
 
     @GeneratedTest

In the output of this run you can see the following message

Calculating task graph as configuration cache cannot be reused because the file system entry 'build/kover/.artifact' has been created.

If you run the build three times, on the third attempt the configuration cache will be re-used, if you apply the patch below the test passes, but it should already be available after the first attempt.

Index: kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt
--- a/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(revision 8ca086b84546bdac370b81039ad4444022b276b8)
+++ b/kover-gradle-plugin/src/functionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/ConfigurationCacheTests.kt	(date 1719477172444)
@@ -29,6 +29,21 @@
             "koverVerify",
             "--configuration-cache",
         )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+        )
+        run(
+            "build",
+            "koverXmlReport",
+            "koverHtmlReport",
+            "koverVerify",
+            "--configuration-cache",
+            checker = { output.match { assertContains("Reusing configuration cache.") } }
+        )
     }
 
     @GeneratedTest

Environment

  • Kover Gradle Plugin version: 0.8.0
  • Gradle version: Any
  • Kotlin project type: Any
  • Coverage Toolset (if customized in build script): Kover only
  • Other context important for this bug: None

Thanks for the report and the test!

Fixed in 0.8.2