[IC][MPP] Upgrade tests for incremental scenarios with expect-actual
Existing tests were k1-only in CI. Simplified test project, added assertions for native. Switched to the new test Dsl. ^KT-61845 duplicates KT-61590 ^KT-56963 in progress Merge-request: KT-MR-12651 Merged-by: Evgenii Mazhukin <evgenii.mazhukin@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
1556925358
commit
6ed7e83378
+1
-5
@@ -9,15 +9,14 @@ import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.replaceFirst
|
||||
import org.jetbrains.kotlin.gradle.util.replaceText
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
@DisplayName("Incremental scenarios with associated compilation")
|
||||
@JvmGradlePluginTests
|
||||
class AssociatedCompilationIT : KGPBaseTest() {
|
||||
override val defaultBuildOptions: BuildOptions
|
||||
get() = super.defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("Rebuild forced if associated compilation changes")
|
||||
@GradleTest
|
||||
fun testRebuildOnAssociatedCompilationChange(gradleVersion: GradleVersion) {
|
||||
@@ -38,7 +37,6 @@ class AssociatedCompilationIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("Rebuild after used internal ABI change in associated compilation")
|
||||
@GradleTest
|
||||
fun testRebuildOnUsedApiChangeInAssociatedCompilation(gradleVersion: GradleVersion) {
|
||||
@@ -55,7 +53,6 @@ class AssociatedCompilationIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("No rebuild after private ABI change in associated compilation")
|
||||
@GradleTest
|
||||
fun testNoRebuildOnPrivateChangeInAssociatedCompilation(gradleVersion: GradleVersion) {
|
||||
@@ -71,7 +68,6 @@ class AssociatedCompilationIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
@DisplayName("No rebuild after unused ABI change in associated compilation")
|
||||
@GradleTest
|
||||
fun testNoRebuildOnUnusedInternalChangeInAssociatedCompilation(gradleVersion: GradleVersion) {
|
||||
|
||||
-40
@@ -1372,46 +1372,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
val libCommonClassKt = projectDir.getFileByName("LibCommonClass.kt")
|
||||
val libCommonClassJsKt = projectDir.getFileByName("LibCommonClassJs.kt")
|
||||
libCommonClassJsKt.modify { it.checkedReplace("platform = \"js\"", "platform = \"Kotlin/JS\"") }
|
||||
|
||||
val libCommonClassJvmKt = projectDir.getFileByName("LibCommonClassJvm.kt")
|
||||
libCommonClassJvmKt.modify { it.checkedReplace("platform = \"jvm\"", "platform = \"Kotlin/JVM\"") }
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(project.relativize(libCommonClassKt, libCommonClassJsKt, libCommonClassJvmKt))
|
||||
}
|
||||
|
||||
val libJvmPlatformUtilKt = projectDir.getFileByName("libJvmPlatformUtil.kt")
|
||||
libJvmPlatformUtilKt.modify {
|
||||
it.checkedReplace("fun libJvmPlatformUtil", "inline fun libJvmPlatformUtil")
|
||||
}
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
val useLibJvmPlatformUtilKt = projectDir.getFileByName("useLibJvmPlatformUtil.kt")
|
||||
assertCompiledKotlinSources(project.relativize(libJvmPlatformUtilKt, useLibJvmPlatformUtilKt))
|
||||
}
|
||||
|
||||
val libJsPlatformUtilKt = projectDir.getFileByName("libJsPlatformUtil.kt")
|
||||
libJsPlatformUtilKt.modify {
|
||||
it.checkedReplace("fun libJsPlatformUtil", "inline fun libJsPlatformUtil")
|
||||
}
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
val useLibJsPlatformUtilKt = projectDir.getFileByName("useLibJsPlatformUtil.kt")
|
||||
assertCompiledKotlinSources(project.relativize(libJsPlatformUtilKt, useLibJsPlatformUtilKt))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPomRewritingInSinglePlatformProject() = with(Project("kt-27059-pom-rewriting")) {
|
||||
setupWorkingDir()
|
||||
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.mpp
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.replaceFirst
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.appendText
|
||||
|
||||
@DisplayName("Incremental scenarios with expect/actual - K2")
|
||||
@MppGradlePluginTests
|
||||
open class ExpectActualIncrementalCompilationIT : KGPBaseTest() {
|
||||
override val defaultBuildOptions: BuildOptions
|
||||
get() = super.defaultBuildOptions.copyEnsuringK2()
|
||||
|
||||
@DisplayName("Base test case - local change, local recompilation")
|
||||
@GradleTest
|
||||
fun testStrictlyLocalChange(gradleVersion: GradleVersion) {
|
||||
nativeProject("expect-actual-fun-or-class-ic", gradleVersion) {
|
||||
build("assemble")
|
||||
|
||||
val valueKtPath = kotlinSourcesDir("commonMain").resolve("Value.kt")
|
||||
valueKtPath.appendText("val irrelevant = 2")
|
||||
|
||||
build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertTasksExecuted(":compileKotlinJvm", ":compileKotlinJs", ":compileKotlinNative")
|
||||
assertIncrementalCompilation(listOf(valueKtPath).relativizeTo(projectPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("File with actual declaration needs recompiling")
|
||||
@GradleTest
|
||||
fun testRecompilationOfActualFun(gradleVersion: GradleVersion) {
|
||||
nativeProject("expect-actual-fun-or-class-ic", gradleVersion) {
|
||||
build("assemble")
|
||||
|
||||
listOf(
|
||||
kotlinSourcesDir("jvmMain").resolve("FooJvm.kt"),
|
||||
kotlinSourcesDir("nativeMain").resolve("FooNative.kt"),
|
||||
kotlinSourcesDir("jsMain").resolve("FooJs.kt")
|
||||
).forEach {
|
||||
it.replaceFirst("\"foo", "\"bar")
|
||||
}
|
||||
|
||||
build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertTasksExecuted(":compileKotlinJvm", ":compileKotlinJs", ":compileKotlinNative")
|
||||
assertIncrementalCompilation(
|
||||
listOf(
|
||||
kotlinSourcesDir("jvmMain").resolve("FooJvm.kt"),
|
||||
kotlinSourcesDir("jsMain").resolve("FooJs.kt"),
|
||||
kotlinSourcesDir("commonMain").resolve("Foo.kt")
|
||||
).relativizeTo(projectPath)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("File with expect declaration needs recompiling indirectly")
|
||||
@GradleTest
|
||||
fun testRecompilationOfExpectFun(gradleVersion: GradleVersion) {
|
||||
nativeProject("expect-actual-fun-or-class-ic", gradleVersion) {
|
||||
build("assemble")
|
||||
|
||||
val valueKtPath = kotlinSourcesDir("commonMain").resolve("Value.kt")
|
||||
valueKtPath.replaceFirst(
|
||||
"val secret = 1",
|
||||
"val secret = \"k2\""
|
||||
)
|
||||
|
||||
build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertTasksExecuted(":compileKotlinJvm", ":compileKotlinJs", ":compileKotlinNative")
|
||||
assertIncrementalCompilation(
|
||||
listOf(
|
||||
kotlinSourcesDir("jvmMain").resolve("FooJvm.kt"),
|
||||
kotlinSourcesDir("jsMain").resolve("FooJs.kt"),
|
||||
kotlinSourcesDir("commonMain").resolve("Foo.kt"),
|
||||
valueKtPath
|
||||
).relativizeTo(projectPath)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("File with expect class declaration needs recompiling")
|
||||
@GradleTest
|
||||
fun testRecompilationOfExpectClass(gradleVersion: GradleVersion) {
|
||||
nativeProject("expect-actual-fun-or-class-ic", gradleVersion) {
|
||||
build("assemble")
|
||||
|
||||
kotlinSourcesDir("commonMain").resolve("Bar.kt").appendText("val irrelevant = 2")
|
||||
|
||||
build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertTasksExecuted(":compileKotlinJvm", ":compileKotlinJs", ":compileKotlinNative")
|
||||
assertIncrementalCompilation(listOf("commonMain", "jvmMain", "jsMain").map { sourceSet ->
|
||||
kotlinSourcesDir(sourceSet).resolve("Bar.kt")
|
||||
}.relativizeTo(projectPath))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Incremental scenarios with expect/actual - K1")
|
||||
class ExpectActualIncrementalCompilationK1IT : ExpectActualIncrementalCompilationIT() {
|
||||
override val defaultBuildOptions: BuildOptions
|
||||
get() = super.defaultBuildOptions.copyEnsuringK1()
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js(IR) { browser { } }
|
||||
<SingleNativeTarget>("native")
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expect class Bar {
|
||||
val version: Int
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expect fun foo(): Any
|
||||
|
||||
fun fooImpl() = secret
|
||||
+1
@@ -0,0 +1 @@
|
||||
val secret = 1
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
actual class Bar {
|
||||
actual val version: Int = 2
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
actual fun foo(): Any = "fooJs"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
actual class Bar {
|
||||
actual val version: Int = 3
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
actual fun foo(): Any = "fooJvm"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
actual class Bar {
|
||||
actual val version: Int = 1
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
actual fun foo(): Any = "fooNative"
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
apply from: "$rootDir/configure-targets.gradle"
|
||||
|
||||
kotlin.sourceSets.commonMain {
|
||||
dependencies {
|
||||
implementation project(":lib")
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
expect class AppCommonClass {
|
||||
val platform: String
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class AppCommonDummy
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
actual class AppCommonClass {
|
||||
actual val platform = "js"
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class AppJsDummy
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun useLibJsPlatformUtil() = libJsPlatformUtil()
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
actual class AppCommonClass {
|
||||
actual val platform = "jvm"
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class AppJvmDummy
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun useLibJvmPlatformUtil() = libJvmPlatformUtil()
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
apply plugin: "kotlin-multiplatform"
|
||||
|
||||
kotlin {
|
||||
jvm {}
|
||||
js(IR) {}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common'
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
||||
}
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-js'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
apply from: "$rootDir/configure-targets.gradle"
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
expect class LibCommonClass {
|
||||
val platform: String
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class LibCommonDummy
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
actual class LibCommonClass {
|
||||
actual val platform = "js"
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class LibJsDummy
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun libJsPlatformUtil(): Int = 0
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
actual class LibCommonClass {
|
||||
actual val platform = "jvm"
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class LibJvmDummy
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
fun libJvmPlatformUtil(): Int = 0
|
||||
-1
@@ -1 +0,0 @@
|
||||
include ':app', ':lib'
|
||||
Reference in New Issue
Block a user