[ObjCExport] Fe10: Implement test with exported and non exported klib dependencies
KT-65670
This commit is contained in:
committed by
Space Team
parent
b26f9cb274
commit
e377a98815
+1
-1
@@ -167,7 +167,7 @@ fun Project.configureKotlinCompilationOptions() {
|
||||
// This is a workaround for KT-50876, but with no clear explanation why doFirst is used.
|
||||
// However, KGP with Native targets is used in the native-xctest project, and this code fails with
|
||||
// The value for property 'freeCompilerArgs' is final and cannot be changed any further.
|
||||
if (project.path != ":native:kotlin-test-native-xctest") {
|
||||
if (project.path != ":native:kotlin-test-native-xctest" && !project.path.startsWith(":native:objcexport-header-generator")) {
|
||||
doFirst {
|
||||
if (!useAbsolutePathsInKlib) {
|
||||
@Suppress("DEPRECATION")
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Used in for modules in 'native/objcexport-heade-generator/testDependencies.
|
||||
* Such libraries can build klibs that can then later be used for running objc export tests against
|
||||
*/
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
/*
|
||||
Depends on https://youtrack.jetbrains.com/issue/KT-65985
|
||||
*/
|
||||
providers.systemProperty("kotlin.internal.native.test.nativeHome").orNull?.let { nativeHome ->
|
||||
extensions.extraProperties.set("kotlin.native.home", nativeHome)
|
||||
}
|
||||
|
||||
kotlin {
|
||||
macosArm64()
|
||||
macosX64()
|
||||
linuxX64()
|
||||
linuxArm64()
|
||||
mingwX64()
|
||||
}
|
||||
+49
@@ -1,5 +1,16 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.gradle.api.tasks.PathSensitivity
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.gradle.kotlin.dsl.project
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import java.io.File
|
||||
|
||||
/*
|
||||
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
@@ -19,11 +30,49 @@ fun Project.objCExportHeaderGeneratorTest(
|
||||
tag = null,
|
||||
requirePlatformLibs = false,
|
||||
) {
|
||||
/**
|
||||
* Setup klib dependencies that can be used in tests:
|
||||
* The resolved klibs will be available as classpath under the `testDependencyKlibs` System property.
|
||||
*/
|
||||
run {
|
||||
/* Configuration to resolve klibs for the current host */
|
||||
val testDependencyKlibs = configurations.maybeCreate("testDependencyKlibs").also { configuration ->
|
||||
configuration.attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_API))
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.native)
|
||||
attribute(KotlinNativeTarget.konanTargetAttribute, HostManager.host.name)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
configuration(project(":native:objcexport-header-generator:testLibraryA"))
|
||||
configuration(project(":native:objcexport-header-generator:testLibraryB"))
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a classpath (list of file paths) that will be exposed as System property */
|
||||
val testDependencyKlibsClasspath = testDependencyKlibs.incoming.files.elements.map { elements ->
|
||||
elements.joinToString(File.pathSeparator) { location -> location.asFile.absolutePath }
|
||||
}
|
||||
|
||||
doFirst {
|
||||
systemProperty("testDependencyKlibs", testDependencyKlibsClasspath.get())
|
||||
}
|
||||
|
||||
/* Add dependency files as inputs to this test task */
|
||||
inputs.files(testDependencyKlibs).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
}
|
||||
|
||||
useJUnitPlatform()
|
||||
enableJunit5ExtensionsAutodetection()
|
||||
|
||||
/* Special 'Kotlin in Fleet' flag that can switch test mode to 'local development' */
|
||||
systemProperty("kif.local", project.providers.gradleProperty("kif.local").isPresent)
|
||||
|
||||
/* Tests will show this displayName as an additional tag (e.g., to differentiate between K1 and AA tests) */
|
||||
if (testDisplayNameTag != null) {
|
||||
systemProperty("testDisplayName.tag", testDisplayNameTag)
|
||||
}
|
||||
|
||||
configure()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user