Implement fallback strategies

This commit is contained in:
Alexey Tsvetkov
2016-11-17 22:17:09 +03:00
parent d636803d2f
commit 75133bdfb9
6 changed files with 265 additions and 4 deletions
@@ -0,0 +1,54 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.junit.Test
class ExecutionStrategyIT(): BaseGradleIT() {
companion object {
private const val GRADLE_VERSION = "2.10"
}
@Test
fun testDaemon() {
doTestExecutionStrategy("daemon")
}
@Test
fun testInProcess() {
doTestExecutionStrategy("in-process")
}
@Test
fun testOutOfProcess() {
doTestExecutionStrategy("out-of-process")
}
private fun doTestExecutionStrategy(executionStrategy: String) {
val project = Project("kotlinBuiltins", GRADLE_VERSION)
setupProject(project)
val strategyCLIArg = "-Dkotlin.compiler.execution.strategy=$executionStrategy"
val finishMessage = "Finished executing kotlin compiler using $executionStrategy strategy"
project.build("build", strategyCLIArg) {
assertSuccessful()
assertContains(finishMessage)
checkOutput()
}
val fKt = project.projectDir.getFileByName("f.kt")
fKt.delete()
project.build("build", strategyCLIArg) {
assertFailed()
assertContains(finishMessage)
assert(output.contains("Unresolved reference: f", ignoreCase = true))
}
}
protected open fun setupProject(project: Project) {
}
protected open fun CompiledProject.checkOutput() {
assertFileExists("app/build/classes/main/foo/MainKt.class")
}
}
@@ -17,6 +17,7 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
project.build("compileDeployKotlin", "build") {
assertSuccessful()
assertContains("Finished executing kotlin compiler using daemon strategy")
assertReportExists("build/reports/tests/classes/demo.TestSource.html")
assertContains(":compileKotlin", ":compileTestKotlin", ":compileDeployKotlin")
}
@@ -0,0 +1,3 @@
package foo
fun f(fn: (x: Int)->Unit) {}
@@ -1,3 +1,5 @@
package foo
fun f(fn: (x: Int)->Unit) {}
fun main() {
f { it * 2 }
}