Skip to content

Commit c4586a6

Browse files
mMaxySpace Team
authored andcommitted
KT-80205: add plugin path option to swift compilation, so that Testing framework is located ^KT-80205 fixed
Merge-request: KT-MR-23159 Merged-by: Artem Olkov <[email protected]> (cherry picked from commit a433e55)
1 parent 0f317d2 commit c4586a6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/support/settings/TestProcessSettings.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,20 @@ internal class XCTestRunner(val isEnabled: Boolean, private val nativeTargets: K
326326
"${targetPlatform()}/Developer/Library/Frameworks/"
327327
}
328328

329+
// absent on xcode pre 26, we can drop the optionality as soon as we drop xcode 16
330+
val toolchainPath: String? by lazy {
331+
val result = try {
332+
runProcess(
333+
"/usr/bin/xcrun",
334+
"--show-toolchain-path"
335+
)
336+
} catch (_: Throwable) {
337+
return@lazy null
338+
}
339+
340+
result.stdout.trim()
341+
}
342+
329343
private fun targetPlatform(): String {
330344
val xcodeTarget = when (val target = nativeTargets.testTarget) {
331345
KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64 -> "macosx"
@@ -350,6 +364,7 @@ internal class XCTestRunner(val isEnabled: Boolean, private val nativeTargets: K
350364
}
351365

352366
val Settings.systemFrameworksPath: String get() = get<XCTestRunner>().frameworksPath
367+
val Settings.systemToolchainPath: String? get() = get<XCTestRunner>().toolchainPath
353368

354369
/**
355370
* A custom (i.e., the second, an alternative) distribution of the Kotlin/Native compiler.

native/swift/swift-export-standalone-integration-tests/src/org/jetbrains/kotlin/swiftexport/standalone/test/AbstractSwiftExportExecutionTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestExecutable
1717
import org.jetbrains.kotlin.konan.test.blackbox.support.runner.TestRunners.createProperTestRunner
1818
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeTargets
1919
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.systemFrameworksPath
20+
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.systemToolchainPath
2021
import org.jetbrains.kotlin.swiftexport.standalone.SwiftExportModule
2122
import org.jetbrains.kotlin.utils.KotlinNativePaths
2223
import org.junit.jupiter.api.Assumptions
@@ -81,14 +82,15 @@ abstract class AbstractSwiftExportExecutionTest : AbstractSwiftExportTest() {
8182
"-L", it.rootDir.absolutePath,
8283
"-l${it.moduleName}",
8384
)
84-
} + listOf(
85+
} + listOfNotNull(
8586
"-Xcc", "-fmodule-map-file=${Distribution(KotlinNativePaths.homePath.absolutePath).kotlinRuntimeForSwiftModuleMap}",
8687
"-L", kotlinBinaryLibrary.libraryFile.parentFile.absolutePath,
8788
"-l${kotlinBinaryLibrary.libraryFile.nameWithoutExtension.removePrefix("lib")}",
8889

8990
"-F", testRunSettings.systemFrameworksPath,
9091
"-Xlinker", "-rpath", "-Xlinker", testRunSettings.systemFrameworksPath,
91-
"-framework", "Testing"
92+
"-framework", "Testing",
93+
testRunSettings.systemToolchainPath?.let { "-plugin-path ${it}/usr/lib/swift/host/plugins/testing/" }
9294
)
9395

9496
val success = SwiftCompilation(

0 commit comments

Comments
 (0)