[Gradle, K/N] Add more cases for cinterop test
This commit is contained in:
+20
-17
@@ -687,24 +687,27 @@ class GeneralNativeIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCinterop() {
|
fun testCinterop() = with(transformNativeTestProjectWithPluginDsl("native-cinterop")) {
|
||||||
with(transformNativeTestProjectWithPluginDsl("native-cinterop")) {
|
fun libraryFiles(projectName: String, cinteropName: String) = listOf(
|
||||||
build(":build") {
|
"$projectName/build/classes/kotlin/host/main/${projectName}-cinterop-$cinteropName.klib",
|
||||||
assertSuccessful()
|
"$projectName/build/classes/kotlin/host/main/${projectName}.klib",
|
||||||
assertFileExists("build/libs/host/main/native-cinterop-cinterop-number.klib")
|
"$projectName/build/classes/kotlin/host/test/${projectName}_test.klib",
|
||||||
assertFileExists("build/classes/kotlin/host/main/native-cinterop-cinterop-number.klib")
|
)
|
||||||
assertFileExists("build/classes/kotlin/host/test/native-cinterop_test.klib")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that changing the compiler version in properties causes interop reprocessing and source recompilation.
|
build(":projectLibrary:build") {
|
||||||
val hostLibraryTasks = listOf(
|
assertSuccessful()
|
||||||
":cinteropNumberHost",
|
assertTasksExecuted(":projectLibrary:cinteropAnotherNumberHost")
|
||||||
":compileKotlinHost"
|
libraryFiles("projectLibrary", "anotherNumber").forEach { assertFileExists(it) }
|
||||||
)
|
}
|
||||||
build(":build") {
|
|
||||||
assertSuccessful()
|
build(":publishedLibrary:build", ":publishedLibrary:publish") {
|
||||||
assertTasksUpToDate(hostLibraryTasks)
|
assertSuccessful()
|
||||||
}
|
assertTasksExecuted(":publishedLibrary:cinteropNumberHost")
|
||||||
|
libraryFiles("publishedLibrary", "number").forEach { assertFileExists(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
build(":build") {
|
||||||
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -5,12 +5,22 @@ plugins {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url 'repo' }
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
sourceSets {
|
||||||
|
hostMain {
|
||||||
|
dependencies {
|
||||||
|
implementation project(':projectLibrary')
|
||||||
|
implementation 'org.example:publishedLibrary:1.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<SingleNativeTarget>("host") {
|
<SingleNativeTarget>("host") {
|
||||||
compilations.main.cinterops {
|
compilations.test.cinterops {
|
||||||
number {
|
testNumber {
|
||||||
packageName 'example.cinterop.project'
|
packageName 'example.cinterop.project'
|
||||||
extraOpts '-nodefaultlibs'
|
extraOpts '-nodefaultlibs'
|
||||||
compilerOpts '-DEVEN_NUMBER'
|
compilerOpts '-DEVEN_NUMBER'
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.jetbrains.kotlin.multiplatform")
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
<SingleNativeTarget>("host") {
|
||||||
|
compilations.main.cinterops {
|
||||||
|
anotherNumber {
|
||||||
|
packageName 'library.cinterop.project'
|
||||||
|
extraOpts '-nodefaultlibs'
|
||||||
|
compilerOpts '-DEVEN_NUMBER'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 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 library.cinterop.project
|
||||||
|
|
||||||
|
fun projectAnswer(): Int {
|
||||||
|
return getAnotherNumber() * 2
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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 library.cinterop.project
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAnswer() {
|
||||||
|
assertEquals(8, projectAnswer())
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
compilerOpts.osx = -D_ANSI_SOURCE
|
||||||
|
---
|
||||||
|
|
||||||
|
int getAnotherNumber()
|
||||||
|
{
|
||||||
|
#ifdef EVEN_NUMBER
|
||||||
|
return 4;
|
||||||
|
#else
|
||||||
|
return 3;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.jetbrains.kotlin.multiplatform")
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'org.example'
|
||||||
|
version = '1.0'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
<SingleNativeTarget>("host") {
|
||||||
|
compilations.main.cinterops {
|
||||||
|
number {
|
||||||
|
packageName 'library.cinterop.project'
|
||||||
|
extraOpts '-nodefaultlibs'
|
||||||
|
compilerOpts '-DEVEN_NUMBER'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = '../repo'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 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 library.cinterop.project
|
||||||
|
|
||||||
|
fun publishedAnswer(): Int {
|
||||||
|
return getNumber() * 2
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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 library.cinterop.project
|
||||||
|
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAnswer() {
|
||||||
|
assertEquals(4, publishedAnswer())
|
||||||
|
}
|
||||||
+3
@@ -9,3 +9,6 @@ pluginManagement {
|
|||||||
enableFeaturePreview('GRADLE_METADATA')
|
enableFeaturePreview('GRADLE_METADATA')
|
||||||
|
|
||||||
rootProject.name = "native-cinterop"
|
rootProject.name = "native-cinterop"
|
||||||
|
|
||||||
|
include 'projectLibrary'
|
||||||
|
include 'publishedLibrary'
|
||||||
+7
-3
@@ -5,8 +5,12 @@
|
|||||||
|
|
||||||
package example.cinterop.project
|
package example.cinterop.project
|
||||||
|
|
||||||
import example.cinterop.project.*
|
import library.cinterop.project.*
|
||||||
|
|
||||||
fun answer(): Int {
|
fun libraryAnswer(): Int {
|
||||||
return getNumber() * 2
|
return publishedAnswer() + projectAnswer()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selfCalculatedAnswer(): Int {
|
||||||
|
return getNumber() * 2 + getAnotherNumber() * 2
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -7,6 +7,8 @@ package example.cinterop.project
|
|||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun compilerOptsTest() {
|
fun testAnswer() {
|
||||||
assertEquals(4, answer())
|
assertEquals(12, libraryAnswer())
|
||||||
|
assertEquals(12, selfCalculatedAnswer())
|
||||||
|
assertEquals(5, getTestNumber())
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
compilerOpts.osx = -D_ANSI_SOURCE
|
||||||
|
---
|
||||||
|
|
||||||
|
int getTestNumber()
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user