[Native][tests] Extract Clang invocation to a separate function
This commit is contained in:
committed by
Space Team
parent
e311b95893
commit
13618fc03b
+6
-16
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.settings.PipelineType
|
|||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Timeouts
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.util.LLDBSessionSpec
|
import org.jetbrains.kotlin.konan.test.blackbox.support.util.LLDBSessionSpec
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.util.compileWithClang
|
||||||
import org.junit.jupiter.api.Assumptions
|
import org.junit.jupiter.api.Assumptions
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -222,22 +223,11 @@ class ObjCToKotlinSteppingInLLDBTest : AbstractNativeSimpleTest() {
|
|||||||
val clangExecutableName = "clangMain"
|
val clangExecutableName = "clangMain"
|
||||||
val executableFile = File(buildDir, clangExecutableName)
|
val executableFile = File(buildDir, clangExecutableName)
|
||||||
|
|
||||||
// FIXME: absoluteTargetToolchain might not work correctly with KONAN_USE_INTERNAL_SERVER because
|
compileWithClang(
|
||||||
// :kotlin-native:dependencies:update is not a dependency of :native:native.tests:test where this test runs
|
sourceFiles = listOf(clangFile),
|
||||||
val process = ProcessBuilder(
|
outputFile = executableFile,
|
||||||
"${testRunSettings.configurables.absoluteTargetToolchain}/bin/clang",
|
frameworkDirectories = listOf(buildDir),
|
||||||
clangFile.absolutePath,
|
)
|
||||||
"-isysroot", testRunSettings.configurables.absoluteTargetSysRoot,
|
|
||||||
"-target", testRunSettings.configurables.targetTriple.toString(),
|
|
||||||
"-g", "-fmodules",
|
|
||||||
"-F", buildDir.absolutePath,
|
|
||||||
"-o", executableFile.absolutePath
|
|
||||||
).redirectErrorStream(true).start()
|
|
||||||
val clangOutput = process.inputStream.readBytes()
|
|
||||||
|
|
||||||
check(
|
|
||||||
process.waitFor() == 0
|
|
||||||
) { clangOutput.decodeToString() }
|
|
||||||
|
|
||||||
// 4. Generate the test case
|
// 4. Generate the test case
|
||||||
val testExecutable = TestExecutable(
|
val testExecutable = TestExecutable(
|
||||||
|
|||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.test.blackbox.support.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.AbstractNativeSimpleTest
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.configurables
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
// FIXME: absoluteTargetToolchain might not work correctly with KONAN_USE_INTERNAL_SERVER because
|
||||||
|
// :kotlin-native:dependencies:update is not a dependency of :native:native.tests:test where this test runs
|
||||||
|
internal fun AbstractNativeSimpleTest.compileWithClang(
|
||||||
|
sourceFiles: List<File>,
|
||||||
|
outputFile: File,
|
||||||
|
frameworkDirectories: List<File>
|
||||||
|
) {
|
||||||
|
val process = ProcessBuilder(
|
||||||
|
"${testRunSettings.configurables.absoluteTargetToolchain}/bin/clang",
|
||||||
|
*sourceFiles.map { it.absolutePath }.toTypedArray(),
|
||||||
|
"-isysroot", testRunSettings.configurables.absoluteTargetSysRoot,
|
||||||
|
"-target", testRunSettings.configurables.targetTriple.toString(),
|
||||||
|
"-g", "-fmodules",
|
||||||
|
*frameworkDirectories.flatMap { listOf("-F", it.absolutePath) }.toTypedArray(),
|
||||||
|
"-o", outputFile.absolutePath
|
||||||
|
).redirectErrorStream(true).start()
|
||||||
|
val clangOutput = process.inputStream.readBytes()
|
||||||
|
|
||||||
|
check(
|
||||||
|
process.waitFor() == 0
|
||||||
|
) { clangOutput.decodeToString() }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user