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
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
class JavaUpToDateIT : BaseGradleIT() {
|
||||
@Test
|
||||
fun testKotlinMethodBodyIsChanged() {
|
||||
val project = Project("javaUpToDate")
|
||||
@SimpleGradlePluginTests
|
||||
class JavaUpToDateIT : KGPBaseTest() {
|
||||
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||
}
|
||||
@DisplayName("On Kotlin method body change")
|
||||
@GradleTest
|
||||
fun testKotlinMethodBodyIsChanged(gradleVersion: GradleVersion) {
|
||||
project("javaUpToDate", gradleVersion) {
|
||||
build("build") {
|
||||
assertTasksExecuted(
|
||||
":compileKotlin",
|
||||
":compileJava",
|
||||
":compileTestKotlin",
|
||||
":compileTestJava"
|
||||
)
|
||||
}
|
||||
|
||||
project.projectFile("MainKotlinClass.kt").modify {
|
||||
it.replace(
|
||||
"fun number(): Int = 0",
|
||||
"fun number(): Int = 1"
|
||||
)
|
||||
}
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
||||
it.replace(
|
||||
"fun number(): Int = 0",
|
||||
"fun number(): Int = 1"
|
||||
)
|
||||
}
|
||||
|
||||
build("build") {
|
||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinNewLineAdded() {
|
||||
val project = Project("javaUpToDate")
|
||||
@DisplayName("On Kotlin source new newline")
|
||||
@GradleTest
|
||||
fun testKotlinNewLineAdded(gradleVersion: GradleVersion) {
|
||||
project("javaUpToDate", gradleVersion) {
|
||||
build("build") {
|
||||
assertTasksExecuted(
|
||||
":compileKotlin",
|
||||
":compileJava",
|
||||
":compileTestKotlin",
|
||||
":compileTestJava"
|
||||
)
|
||||
}
|
||||
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||
}
|
||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify { "\n$it" }
|
||||
|
||||
project.projectFile("MainKotlinClass.kt").modify { "\n$it" }
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||
build("build") {
|
||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||
assertTasksUpToDate(":compileJava", ":compileTestJava")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrivateMethodSignatureChanged() {
|
||||
val project = Project("javaUpToDate")
|
||||
@DisplayName("On Kotlin private method return type change")
|
||||
@GradleTest
|
||||
fun testPrivateMethodSignatureChanged(gradleVersion: GradleVersion) {
|
||||
project("javaUpToDate", gradleVersion) {
|
||||
build("build") {
|
||||
assertTasksExecuted(
|
||||
":compileKotlin",
|
||||
":compileJava",
|
||||
":compileTestKotlin",
|
||||
":compileTestJava"
|
||||
)
|
||||
}
|
||||
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||
}
|
||||
projectPath.resolve("src/main/kotlin/foo/MainKotlinClass.kt").modify {
|
||||
it.replace(
|
||||
"private fun privateMethod() = 0",
|
||||
"private fun privateMethod() = \"0\""
|
||||
)
|
||||
}
|
||||
|
||||
project.projectFile("MainKotlinClass.kt").modify {
|
||||
it.replace(
|
||||
"private fun privateMethod() = 0",
|
||||
"private fun privateMethod() = \"0\""
|
||||
)
|
||||
}
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
// see https://github.com/gradle/gradle/issues/5013
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||
build("build") {
|
||||
// see https://github.com/gradle/gradle/issues/5013
|
||||
assertTasksExecuted(":compileKotlin", ":compileJava", ":compileTestKotlin", ":compileTestJava")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user