From 93e92cbf74d53191cd0eb8f8b6c1f81eba3b3c3d Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Wed, 1 Feb 2023 16:45:06 +0100 Subject: [PATCH] [Gradle] Implement KT37051CInteropArtifactTest ^KT-37051 Verification Pending --- .../KT37051CInteropArtifactTest.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT37051CInteropArtifactTest.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT37051CInteropArtifactTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT37051CInteropArtifactTest.kt new file mode 100644 index 00000000000..ca56bc30951 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/regressionTests/KT37051CInteropArtifactTest.kt @@ -0,0 +1,43 @@ +/* + * 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("FunctionName") + +package org.jetbrains.kotlin.gradle.regressionTests + +import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension +import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP +import org.junit.Test +import kotlin.test.fail + +class KT37051CInteropArtifactTest { + + @Test + fun `test - cinterop artifact on linuxX64`() { + val project = buildProjectWithMPP() + val kotlin = project.multiplatformExtension + val linuxTarget = kotlin.linuxX64() + val mainCompilation = linuxTarget.compilations.getByName("main") + val cinterop = mainCompilation.cinterops.create("libc") + + val apiElements = project.configurations.getByName(linuxTarget.apiElementsConfigurationName) + + if (apiElements.allDependencies.isNotEmpty()) { + fail("Expected no dependencies in apiElements: ${apiElements.allDependencies}") + } + + if (apiElements.artifacts.size != 2) { + fail("Expected two artifacts in apiElements: main output and cinterop. Found: ${apiElements.artifacts}") + } + + val cinteropArtifact = apiElements.artifacts.filter { artifact -> artifact.classifier == "cinterop-libc" } + .apply { if (size != 1) fail("Expected only one cinterop artifact: Found $this") } + .first() + + if (cinteropArtifact.buildDependencies.getDependencies(null) != setOf(project.tasks.getByName(cinterop.interopProcessingTaskName))) { + fail("Expected cinterop artifact to contain the corresponding cinterop process as task dependency") + } + } +} \ No newline at end of file