[Gradle] Add test for KT-56047

This commit is contained in:
Alexander.Likhachev
2023-01-31 21:23:41 +01:00
committed by Space Team
parent 81072ac9b4
commit 3cc69f691e
@@ -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))
}
}
}
}