[MPP] Add TargetPreset APIs deprecation tests
^KT-59321
This commit is contained in:
committed by
Space Team
parent
da71a152cd
commit
0ad8407b57
+1
@@ -9,6 +9,7 @@ import org.gradle.testkit.runner.BuildResult
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||
import org.jetbrains.kotlin.gradle.internals.VERBOSE_DIAGNOSTIC_SEPARATOR
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.ToolingDiagnosticFactory
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION", "FunctionName")
|
||||
|
||||
package org.jetbrains.kotlin.gradle.unitTests.diagnosticsTests
|
||||
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.util.assertNoDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP
|
||||
import org.jetbrains.kotlin.gradle.util.checkDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.util.kotlin
|
||||
import kotlin.test.*
|
||||
|
||||
class TargetPresetDeprecationTest {
|
||||
|
||||
@Test
|
||||
fun `targetFromPreset usage - emits TargetFromPreset diagnostic`() = checkDiagnostics(
|
||||
"PresetDeprecation-targetFromPreset"
|
||||
) {
|
||||
targetFromPreset(presets.getByName("jvm"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `targets fromPreset usage - emits FromPreset diagnostic`() = checkDiagnostics(
|
||||
"PresetDeprecation-fromPreset"
|
||||
) {
|
||||
targets {
|
||||
fromPreset(presets.getByName("jvm"), "jvm")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `presets createTarget usage - emits CreateTarget diagnostic`() = checkDiagnostics(
|
||||
"PresetDeprecation-createTarget"
|
||||
) {
|
||||
targets.add(presets.getByName("jvm").createTarget("jvm"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `creating target properly - doesn't emit any diagnostics`() = checkDiagnostics(
|
||||
null
|
||||
) {
|
||||
jvm()
|
||||
}
|
||||
|
||||
private fun checkDiagnostics(
|
||||
diagnostic: String?,
|
||||
configure: KotlinMultiplatformExtension.() -> Unit,
|
||||
) {
|
||||
val project = buildProjectWithMPP {
|
||||
kotlin {
|
||||
configure()
|
||||
}
|
||||
}
|
||||
project.evaluate()
|
||||
if (diagnostic != null) {
|
||||
project.checkDiagnostics(diagnostic)
|
||||
} else {
|
||||
project.assertNoDiagnostics()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
[CreateTarget | WARNING] The KotlinTargetPreset.createTarget() API is deprecated and will be removed in future releases. Learn how to configure targets at: https://kotl.in/target-configuration
|
||||
+1
@@ -0,0 +1 @@
|
||||
[FromPreset | WARNING] The fromPreset() API is deprecated and will be removed in future releases. Learn how to configure targets at: https://kotl.in/target-configuration
|
||||
+1
@@ -0,0 +1 @@
|
||||
[TargetFromPreset | WARNING] The targetFromPreset() API is deprecated and will be removed in future releases. Learn how to configure targets at: https://kotl.in/target-configuration
|
||||
Reference in New Issue
Block a user