Migrate JavaUpToDateIT test to new test DSL.
^KT-45747 In Progress
This commit is contained in:
+67
-49
@@ -5,68 +5,86 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
import org.gradle.util.GradleVersion
|
||||||
import org.junit.Test
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
|
||||||
class JavaUpToDateIT : BaseGradleIT() {
|
@SimpleGradlePluginTests
|
||||||
@Test
|
class JavaUpToDateIT : KGPBaseTest() {
|
||||||
fun testKotlinMethodBodyIsChanged() {
|
|
||||||
val project = Project("javaUpToDate")
|
|
||||||
|
|
||||||
project.build("build") {
|
@DisplayName("On Kotlin method body change")
|
||||||
assertSuccessful()
|
@GradleTest
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
fun testKotlinMethodBodyIsChanged(gradleVersion: GradleVersion) {
|
||||||
}
|
project("javaUpToDate", gradleVersion) {
|
||||||
|
build("build") {
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlin",
|
||||||
|
":compileJava",
|
||||||
|
":compileTestKotlin",
|
||||||
|
":compileTestJava"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
project.projectFile("MainKotlinClass.kt").modify {
|
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
||||||
it.replace(
|
it.replace(
|
||||||
"fun number(): Int = 0",
|
"fun number(): Int = 0",
|
||||||
"fun number(): Int = 1"
|
"fun number(): Int = 1"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
build("build") {
|
||||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@DisplayName("On Kotlin source new newline")
|
||||||
fun testKotlinNewLineAdded() {
|
@GradleTest
|
||||||
val project = Project("javaUpToDate")
|
fun testKotlinNewLineAdded(gradleVersion: GradleVersion) {
|
||||||
|
project("javaUpToDate", gradleVersion) {
|
||||||
|
build("build") {
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlin",
|
||||||
|
":compileJava",
|
||||||
|
":compileTestKotlin",
|
||||||
|
":compileTestJava"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
project.build("build") {
|
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify { "\n$it" }
|
||||||
assertSuccessful()
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
|
||||||
}
|
|
||||||
|
|
||||||
project.projectFile("MainKotlinClass.kt").modify { "\n$it" }
|
build("build") {
|
||||||
project.build("build") {
|
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||||
assertSuccessful()
|
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
}
|
||||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@DisplayName("On Kotlin private method return type change")
|
||||||
fun testPrivateMethodSignatureChanged() {
|
@GradleTest
|
||||||
val project = Project("javaUpToDate")
|
fun testPrivateMethodSignatureChanged(gradleVersion: GradleVersion) {
|
||||||
|
project("javaUpToDate", gradleVersion) {
|
||||||
|
build("build") {
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlin",
|
||||||
|
":compileJava",
|
||||||
|
":compileTestKotlin",
|
||||||
|
":compileTestJava"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
project.build("build") {
|
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
||||||
assertSuccessful()
|
it.replace(
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
"private fun privateMethod() = 0",
|
||||||
}
|
"private fun privateMethod() = \"0\""
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
project.projectFile("MainKotlinClass.kt").modify {
|
build("build") {
|
||||||
it.replace(
|
// see https://github.com/gradle/gradle/issues/5013
|
||||||
"private fun privateMethod() = 0",
|
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||||
"private fun privateMethod() = \"0\""
|
}
|
||||||
)
|
|
||||||
}
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
// see https://github.com/gradle/gradle/issues/5013
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user