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

Test tasks sometimes miss the build cache due to overlapping outputs #1103

Open
abrooksv opened this issue Sep 6, 2022 · 2 comments
Open
Labels
Milestone

Comments

@abrooksv
Copy link
Contributor

abrooksv commented Sep 6, 2022

Describe the bug
The Test tasks have their build cache disabled when ran:

The task was not up-to-date because of the following reasons: |  
-- | --
Output property 'binaryResultsDirectory' file build/test-results/test/binary has been removed. |  
Output property 'binaryResultsDirectory' file build/test-results/test/binary/output.bin has been removed. |  
Output property 'binaryResultsDirectory' file build/test-results/test/binary/output.bin.idx has been removed. |  
 
Cache key | 2e67aa93bbea2dbfed0525b9a74b6cd0 |  
Not cacheable | Overlapping outputs: Gradle does not know how file 'build/idea-sandbox/system-test/index/stubs/Stubs.storage.values.at' was created (output property 'System directory'). Task output caching requires exclusive access to output paths to guarantee correctness (i.e. multiple tasks are not allowed to produce output in the same location).

To Reproduce

  1. Run test task with a project that has build cache enabled (org.gradle.caching=true)
  2. delete the outputs of test results to force a re-run (but inputs won't be changed so build cache key should match). I deleted the test-results folder: rm -r build/test-results
  3. Run tests again
  4. See a build scan output as to why the task was re-run instead of FROM_CACHE

I am trying to build a test case but I can't get it to reproduce right now...
master...abrooksv:gradle-intellij-plugin:testBuildCache

Expected behavior
Test results should be pulled from build cache

Side note
Should the system dir not be an output, but a localState property?

Environment:

  • OS: Mac OS
  • Gradle IntelliJ Plugin Version 1.8.1
  • Gradle Version 7.5

Additional context
Add any other context about the problem here.

@abrooksv abrooksv added the bug label Sep 6, 2022
@abrooksv abrooksv changed the title Test tasks always miss the build cache Test tasks sometimes miss the build cache Sep 6, 2022
@abrooksv abrooksv changed the title Test tasks sometimes miss the build cache Test tasks sometimes miss the build cache due to overlapping outputs Sep 6, 2022
@YannCebron
Copy link
Member

what if you change non-code test-data? we can't guess where that possibly comes from

@abrooksv
Copy link
Contributor Author

abrooksv commented Sep 7, 2022

Do you mean you think it's not possible to make it work with the build cache due to outside testdata directory can affect it? Does that not fall into the realm of the user to add

tasks {
    test {
        inputs.dir(project.file("testdata"))
    }
}

?


I could not get the test case to produce the values.at file, but only:

Stubs.storage
Stubs.storage.len
Stubs.storage_i.len
Stubs.ver

but I doubt the specific file matters.


I did run this patch:

Index: src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt b/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt
--- a/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt	(revision a4b137280d3e01810acb18d50605aed4faa18cce)
+++ b/src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt	(date 1662569740738)
@@ -1152,8 +1152,7 @@
             // the same as previous – setting appClassLoader but outdated. Works for part of 203 builds.
             task.systemProperty("idea.use.core.classloader.for", pluginIds.joinToString(","))
 
-            task.outputs.dir(systemDirectoryProvider)
-                .withPropertyName("System directory")
+            task.localState.register(systemDirectoryProvider)
             task.inputs.dir(configDirectoryProvider)
                 .withPropertyName("Config Directory")
                 .withPathSensitivity(PathSensitivity.RELATIVE)

And it works locally with the above steps against our private plugin.

The change is the system dir won't be stored in the build cache anymore.

I can't see a use case for consuming them in a downstream task, only issue that may arise (which could be a problem in and of itself) is that the system-test is shared across all Test tasks, so if you have integ and unit tests, the IDE caches can be reused (but that may also definitely cause overlapping outputs too...)

It does bother me that I can't seem to reproduce it as an integration test 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants