From 3cc69f691eef34757b915644f82cb7b130badc83 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Tue, 31 Jan 2023 21:23:41 +0100 Subject: [PATCH] [Gradle] Add test for KT-56047 --- .../jetbrains/kotlin/gradle/BuildCacheIT.kt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheIT.kt index ff9c639dd79..09b1657aefa 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BuildCacheIT.kt @@ -166,4 +166,38 @@ class BuildCacheIT : KGPBaseTest() { } } + @DisplayName("Restore from build cache and consequent compilation error should not break incremental compilation") + @GradleTest + fun testIncrementalCompilationAfterCacheHitAndCompilationError(gradleVersion: GradleVersion) { + project("incrementalMultiproject", gradleVersion) { + enableLocalBuildCache(localBuildCacheDir) + build("assemble") + build("clean", "assemble") { + assertTasksFromCache(":lib:compileKotlin") + assertTasksFromCache(":app:compileKotlin") + } + val bKtSourceFile = projectPath.resolve("lib/src/main/kotlin/bar/B.kt") + + bKtSourceFile.modify { it.replace("fun b() {}", "fun b() {}\nfun b2) {}") } + + buildAndFail("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) { + assertTasksFailed(":lib:compileKotlin") + assertOutputDoesNotContain("On recompilation full rebuild will be performed") + val affectedFiles = setOf( + bKtSourceFile, + ) + assertCompiledKotlinSources(affectedFiles.relativizeTo(projectPath), output) + } + + bKtSourceFile.modify { it.replace("fun b2) {}", "fun b2() {}") } + + build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) { + val affectedFiles = setOf( + bKtSourceFile, + subProject("app").kotlinSourcesDir().resolve("foo/BB.kt"), + ) + assertIncrementalCompilation(expectedCompiledKotlinFiles = affectedFiles.relativizeTo(projectPath)) + } + } + } }