Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

Configuration Cache can not be used after one run #646

Closed remcomokveld closed 5 months ago

remcomokveld commented 5 months ago

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

shanshin commented 5 months ago

Thanks for the report and the test!

shanshin commented 5 months ago

Fixed in 0.8.2