[Gradle] Implement CInteropIdeaSyncIT to cover ^KT-48882
This commit is contained in:
committed by
Space
parent
ffaaadcfb6
commit
52c6713fff
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.native
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class CInteropIdeaSyncIT : BaseGradleIT() {
|
||||||
|
|
||||||
|
private val ideaSyncBuildOptions = defaultBuildOptions().copy(
|
||||||
|
freeCommandLineArgs = listOf("-Didea.sync.active=true")
|
||||||
|
)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test failing cinterop warning`() {
|
||||||
|
val ideaSyncWarningMessage = "Warning: Failed to generate cinterop for :cinteropSampleInteropNative"
|
||||||
|
val interopTaskName = ":cinteropSampleInteropNative"
|
||||||
|
|
||||||
|
with(Project("cinterop-failing")) {
|
||||||
|
/* Task still fails on 'normal' builds */
|
||||||
|
build("commonize") {
|
||||||
|
assertTasksFailed(interopTaskName)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Task failure is just a warning during import */
|
||||||
|
build("commonize", options = ideaSyncBuildOptions) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(interopTaskName)
|
||||||
|
assertContains(ideaSyncWarningMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Task is not considered up-to-date after lenient failure */
|
||||||
|
build("commonize", options = ideaSyncBuildOptions) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(interopTaskName)
|
||||||
|
assertContains(ideaSyncWarningMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove noise that causes failure */
|
||||||
|
projectDir.resolve("src/nativeInterop/cinterop/sampleInteropNoise.h").writeText("")
|
||||||
|
|
||||||
|
build("commonize", options = ideaSyncBuildOptions) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(interopTaskName)
|
||||||
|
assertNotContains(ideaSyncWarningMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Task is considered up-to-date after first successful run */
|
||||||
|
build("commonize", options = ideaSyncBuildOptions) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksUpToDate(interopTaskName)
|
||||||
|
assertNotContains(ideaSyncWarningMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Task is still considered up-to-date after successful run in idea sync */
|
||||||
|
build("commonize") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksUpToDate(interopTaskName)
|
||||||
|
assertNotContains(ideaSyncWarningMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
val nativeTarget = when {
|
||||||
|
HostManager.hostIsMac -> macosX64("native")
|
||||||
|
HostManager.hostIsMingw -> mingwX64("native")
|
||||||
|
HostManager.hostIsLinux -> linuxX64("native")
|
||||||
|
else -> error("Unexpected host: ${HostManager.host}")
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeTarget.compilations["main"].cinterops.create("sampleInterop") {
|
||||||
|
header(file("src/nativeInterop/cinterop/sampleInterop.h"))
|
||||||
|
header(file("src/nativeInterop/cinterop/sampleInteropNoise.h"))
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
|
kotlin.native.enableDependencyPropagation=false
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
val kotlin_version: String by settings
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform").version(kotlin_version)
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
void sampleInterop() {
|
||||||
|
};
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
This is not a valid header file.
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
import sampleInterop.sampleInterop
|
||||||
|
|
||||||
|
object NativeMain {
|
||||||
|
fun x() = sampleInterop()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user