diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt index 6945fd5b347..6f5bcc70867 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/ExecutorService.kt @@ -183,20 +183,6 @@ val Project.executor: ExecutorService get() = this.extensions.findByName("executor") as? ExecutorService ?: throw IllegalStateException("Executor wasn't found") -/** - * Creates a new executor service with additional action [actionParameter] executed after the main one. - * The following is an example how to pass an environment parameter - * @code `executor.add(Action { it.environment = mapOf("JAVA_OPTS" to "-verbose:gc") })::execute` - */ -fun ExecutorService.add(actionParameter: Action) = object : ExecutorService { - override val project: Project get() = this@add.project - override fun execute(action: Action): ExecResult? = - this@add.execute(Action { - action.execute(this) - actionParameter.execute(this) - }) -} - /** * Executes the [executable] with the given [arguments] * and checks that the program finished with zero exit code. diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt index 2d81df8f933..68b882d51cc 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt @@ -12,11 +12,9 @@ import org.gradle.api.tasks.TaskAction import org.gradle.language.base.plugins.LifecycleBasePlugin import org.jetbrains.kotlin.konan.target.* -import org.jetbrains.kotlin.native.executors.* import java.io.File import java.io.FileWriter import java.io.Serializable -import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -28,7 +26,6 @@ import java.nio.file.Paths * @property swiftSources Swift-language test sources that use a given framework * @property frameworks names of frameworks */ -@OptIn(ExperimentalStdlibApi::class) open class FrameworkTest : DefaultTask(), KonanTestExecutable { @Input lateinit var swiftSources: List @@ -187,53 +184,15 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable { // Build test executable as a first action of the task before executing the test buildTestExecutable() doBeforeRun?.execute(this) - if (project.compileOnlyTests) { - return - } - runTest(executorService = project.executor, testExecutable = Paths.get(executable)) - } - - /** - * Returns path to directory that contains `libswiftCore.dylib` for the current - * test target. - */ - private fun getSwiftLibsPathForTestTarget(): String { - val configs = project.testTargetConfigurables as AppleConfigurables - val swiftPlatform = configs.platformName().toLowerCase() - val simulatorPath = when (configs.targetTriple.isSimulator) { - true -> xcode.getLatestSimulatorRuntimeFor(configs.target.family, configs.osVersionMin) - ?.bundlePath - ?.let { "$it/Contents/Resources/RuntimeRoot/usr/lib/swift" } - else -> null - } - // Use default path from toolchain if we cannot get `bundlePath` for target. - // It may be the case for simulators if Xcode/macOS is old. - return simulatorPath ?: configs.absoluteTargetToolchain + "/usr/lib/swift-5.0/$swiftPlatform" - } - - private fun buildEnvironment(): Map { - val configs = project.testTargetConfigurables - // Hopefully, lexicographical comparison will work. - val newMacos = System.getProperty("os.version").compareTo("10.14.4") >= 0 - val dyldLibraryPathKey = if (configs.targetTriple.isSimulator) { - "SIMCTL_CHILD_DYLD_LIBRARY_PATH" - } else { - "DYLD_LIBRARY_PATH" - } - // TODO: macos_arm64? - return if (newMacos && configs.target == KonanTarget.MACOS_X64) emptyMap() else mapOf( - dyldLibraryPathKey to getSwiftLibsPathForTestTarget() - ) - } - - private fun runTest(executorService: ExecutorService, testExecutable: Path, args: List = emptyList()) { + val testExecutable = Paths.get(executable) val (stdOut, stdErr, exitCode) = runProcess( - executor = { executorService.add(Action { - environment = buildEnvironment() - workingDir = Paths.get(testOutput).toFile() - }).execute(it) }, - executable = testExecutable.toString(), - args = args) + executor = { + project.executor.execute { + it.execute(this) + workingDir = Paths.get(testOutput).toFile() + } + }, + executable = testExecutable.toString()) val testExecName = testExecutable.fileName println(""" @@ -244,8 +203,6 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable { val timeoutMessage = if (exitCode == -1) { "WARNING: probably a timeout\n" } else "" - check(exitCode == expectedExitStatus ?: 0) { "${timeoutMessage}Execution of $testExecName failed with exit code: $exitCode " } + check(exitCode == (expectedExitStatus ?: 0)) { "${timeoutMessage}Execution of $testExecName failed with exit code: $exitCode " } } - - private val xcode by lazy { Xcode.findCurrent() } }