Clear outputs before compiling with in-process/out-of-process execution mode

Issue #KT-30492 Fixed
This commit is contained in:
Alexey Tsvetkov
2019-03-18 21:45:24 +03:00
parent b2ad82b7d2
commit 2ec6ab92b5
6 changed files with 54 additions and 18 deletions
@@ -1,5 +1,6 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.checkedReplace
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
@@ -18,9 +19,29 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() {
override fun CompiledProject.checkOutput() {
assertFileExists("web/js/out.js")
}
override fun CompiledProject.checkOutputAfterChange() {
assertFileExists("web/js/out.js")
}
}
open class ExecutionStrategyIT : BaseGradleIT() {
class ExecutionStrategyJvmIT : ExecutionStrategyIT() {
override fun CompiledProject.checkOutput() {
val classesDir = kotlinClassesDir(subproject = "app") + "foo/"
assertFileExists("${classesDir}MainKt.class")
assertFileExists("${classesDir}A.class")
assertFileExists("${classesDir}B.class")
}
override fun CompiledProject.checkOutputAfterChange() {
val classesDir = kotlinClassesDir(subproject = "app") + "foo/"
assertFileExists("${classesDir}MainKt.class")
assertFileExists("${classesDir}A.class")
assertNoSuchFile("${classesDir}B.class")
}
}
abstract class ExecutionStrategyIT : BaseGradleIT() {
@Test
fun testDaemon() {
doTestExecutionStrategy("daemon")
@@ -48,14 +69,18 @@ open class ExecutionStrategyIT : BaseGradleIT() {
assertContains(finishMessage)
checkOutput()
assertNoWarnings()
assertFileExists(kotlinClassesDir(subproject = "app") + "foo/B.class")
}
val fKt = project.projectDir.getFileByName("f.kt")
fKt.delete()
val classesKt = project.projectDir.getFileByName("classes.kt")
classesKt.modify {
it.checkedReplace("class B", "//class B")
}
project.build("build", strategyCLIArg) {
assertFailed()
assertSuccessful()
assertContains(finishMessage)
assert(output.contains("Unresolved reference: f", ignoreCase = true))
checkOutputAfterChange()
assertNoWarnings()
}
}
@@ -66,7 +91,6 @@ open class ExecutionStrategyIT : BaseGradleIT() {
)
}
protected open fun CompiledProject.checkOutput() {
assertFileExists(kotlinClassesDir(subproject = "app") + "foo/MainKt.class")
}
protected abstract fun CompiledProject.checkOutput()
protected abstract fun CompiledProject.checkOutputAfterChange()
}
@@ -1,4 +0,0 @@
package foo
@Suppress("unused_parameter")
fun f(fn: (x: Int)->Unit) { }
@@ -1,5 +1,5 @@
package foo
fun main() {
f { it * 2 }
A()
}