Support OptionalExpectation in native
This commit is contained in:
+2
-2
@@ -312,9 +312,9 @@ abstract class BaseGradleIT {
|
||||
return this
|
||||
}
|
||||
|
||||
fun CompiledProject.assertContains(vararg expected: String): CompiledProject {
|
||||
fun CompiledProject.assertContains(vararg expected: String, ignoreCase: Boolean = false): CompiledProject {
|
||||
for (str in expected) {
|
||||
assertTrue(output.contains(str.normalize()), "Output should contain '$str'")
|
||||
assertTrue(output.contains(str.normalize(), ignoreCase), "Output should contain '$str'")
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
+17
-7
@@ -477,21 +477,31 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build("compileKotlinJvmWithoutJava") {
|
||||
build("compileKotlinJvmWithoutJava", "compileKotlin${nativeHostTargetName.capitalize()}") {
|
||||
assertSuccessful()
|
||||
assertFileExists(targetClassesDir("jvmWithoutJava") + "OptionalCommonUsage.class")
|
||||
}
|
||||
|
||||
projectDir.resolve("src/jvmWithoutJavaMain/kotlin/OptionalImpl.kt").writeText(
|
||||
"\n" + """
|
||||
val optionalImplText = "\n" + """
|
||||
@Optional("should fail, see KT-25196")
|
||||
class OptionalPlatformUsage
|
||||
""".trimIndent()
|
||||
)
|
||||
""".trimIndent()
|
||||
|
||||
projectDir.resolve("src/jvmWithoutJavaMain/kotlin/OptionalImpl.kt").writeText(optionalImplText)
|
||||
|
||||
build("compileKotlinJvmWithoutJava") {
|
||||
assertFailed()
|
||||
assertContains("Declaration annotated with '@OptionalExpectation' can only be used in common module sources")
|
||||
assertContains("Declaration annotated with '@OptionalExpectation' can only be used in common module sources", ignoreCase = true)
|
||||
}
|
||||
|
||||
projectDir.resolve("src/${nativeHostTargetName}Main/kotlin/").also {
|
||||
it.mkdirs()
|
||||
it.resolve("OptionalImpl.kt").writeText(optionalImplText)
|
||||
}
|
||||
|
||||
build("compileKotlin${nativeHostTargetName.capitalize()}") {
|
||||
assertFailed()
|
||||
assertContains("Declaration annotated with '@OptionalExpectation' can only be used in common module sources", ignoreCase = true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,7 +630,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
@Test
|
||||
fun testNativeCompilerDownloading() {
|
||||
// The plugin shouldn't download the K/N compiler if there is no corresponding targets in the project.
|
||||
with(Project("new-mpp-lib-with-tests", gradleVersion)) {
|
||||
with(Project("sample-old-style-app", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
build("tasks") {
|
||||
assertSuccessful()
|
||||
assertFalse(output.contains("Kotlin/Native distribution: "))
|
||||
|
||||
+8
-1
@@ -22,8 +22,11 @@ repositories {
|
||||
kotlin {
|
||||
targets {
|
||||
fromPreset(presets.jvm, 'jvmWithoutJava')
|
||||
fromPreset(presets.jvmWithJava, 'jvmWithJava')
|
||||
fromPreset(presets.jvmWithJava, 'jvmWithJava')
|
||||
fromPreset(presets.js, 'js')
|
||||
fromPreset(presets.macosX64, 'macos64')
|
||||
fromPreset(presets.linuxX64, 'linux64')
|
||||
fromPreset(presets.mingwX64, 'mingw64')
|
||||
}
|
||||
sourceSets {
|
||||
commonTest {
|
||||
@@ -48,5 +51,9 @@ kotlin {
|
||||
implementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
}
|
||||
}
|
||||
nativeMain
|
||||
configure([macos64Main, linux64Main, mingw64Main]) {
|
||||
dependsOn nativeMain
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package com.example.lib
|
||||
|
||||
actual fun expectedFun() = Unit
|
||||
Reference in New Issue
Block a user