[K/N][tests] Extract Settings.executor
This commit is contained in:
committed by
Space Team
parent
5bd78e1bf2
commit
f0c9033205
+4
-25
@@ -5,37 +5,16 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.konan.test.blackbox.support.runner
|
package org.jetbrains.kotlin.konan.test.blackbox.support.runner
|
||||||
|
|
||||||
import org.jetbrains.kotlin.konan.target.*
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.ForcedNoopTestRunner
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestName
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Settings
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.*
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.executor
|
||||||
import org.jetbrains.kotlin.native.executors.*
|
|
||||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.fail
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
|
||||||
|
|
||||||
internal object TestRunners {
|
internal object TestRunners {
|
||||||
fun createProperTestRunner(testRun: TestRun, settings: Settings): Runner<Unit> = with(settings) {
|
fun createProperTestRunner(testRun: TestRun, settings: Settings): Runner<Unit> = with(settings) {
|
||||||
if (get<ForcedNoopTestRunner>().value) {
|
if (get<ForcedNoopTestRunner>().value) {
|
||||||
NoopTestRunner
|
NoopTestRunner
|
||||||
} else with(get<KotlinNativeTargets>()) {
|
} else {
|
||||||
val executor = executorCache.computeIfAbsent(testTarget) {
|
|
||||||
val configurables = configurables
|
|
||||||
when {
|
|
||||||
configurables.target == hostTarget -> HostExecutor()
|
|
||||||
configurables is ConfigurablesWithEmulator -> EmulatorExecutor(configurables)
|
|
||||||
configurables is AppleConfigurables && configurables.targetTriple.isSimulator ->
|
|
||||||
XcodeSimulatorExecutor(configurables)
|
|
||||||
configurables is AppleConfigurables && RosettaExecutor.availableFor(configurables) -> RosettaExecutor(configurables)
|
|
||||||
else -> runningOnUnsupportedTarget()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RunnerWithExecutor(executor, testRun)
|
RunnerWithExecutor(executor, testRun)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val executorCache: ConcurrentHashMap<KonanTarget, Executor> = ConcurrentHashMap()
|
|
||||||
|
|
||||||
private fun KotlinNativeTargets.runningOnUnsupportedTarget(): Nothing = fail {
|
|
||||||
"Running tests for $testTarget on $hostTarget is not supported yet."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.konan.test.blackbox.support.settings
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.target.AppleConfigurables
|
||||||
|
import org.jetbrains.kotlin.konan.target.ConfigurablesWithEmulator
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
|
import org.jetbrains.kotlin.konan.target.isSimulator
|
||||||
|
import org.jetbrains.kotlin.native.executors.*
|
||||||
|
import org.jetbrains.kotlin.test.services.JUnit5Assertions
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
|
private val executorCache: ConcurrentHashMap<KonanTarget, Executor> = ConcurrentHashMap()
|
||||||
|
|
||||||
|
internal val Settings.executor: Executor
|
||||||
|
get() = with(get<KotlinNativeTargets>()) {
|
||||||
|
executorCache.computeIfAbsent(testTarget) {
|
||||||
|
val configurables = configurables
|
||||||
|
when {
|
||||||
|
configurables.target == hostTarget -> HostExecutor()
|
||||||
|
configurables is ConfigurablesWithEmulator -> EmulatorExecutor(configurables)
|
||||||
|
configurables is AppleConfigurables && configurables.targetTriple.isSimulator ->
|
||||||
|
XcodeSimulatorExecutor(configurables)
|
||||||
|
configurables is AppleConfigurables && RosettaExecutor.availableFor(configurables) -> RosettaExecutor(configurables)
|
||||||
|
else -> JUnit5Assertions.fail { "Running tests for $testTarget on $hostTarget is not supported yet." }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user