Allow setting test binary linker options using a test compilation
#KT-29254 Fixed
This commit is contained in:
+10
-6
@@ -117,6 +117,14 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
|
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
|
||||||
|
|
||||||
|
fun CompiledProject.checkProgramCompilationCommandLine(check: (String) -> Unit) {
|
||||||
|
output.lineSequence().filter {
|
||||||
|
it.contains("Run tool: konanc") && it.contains("-p program")
|
||||||
|
}.toList().also {
|
||||||
|
assertTrue(it.isNotEmpty())
|
||||||
|
}.forEach(check)
|
||||||
|
}
|
||||||
|
|
||||||
fun CompiledProject.checkAppBuild() {
|
fun CompiledProject.checkAppBuild() {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksExecuted(*compileTasksNames.toTypedArray())
|
assertTasksExecuted(*compileTasksNames.toTypedArray())
|
||||||
@@ -154,12 +162,8 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
assertFileExists("build/bin/$nativeHostTargetName/mainReleaseExecutable/$nativeExeName")
|
assertFileExists("build/bin/$nativeHostTargetName/mainReleaseExecutable/$nativeExeName")
|
||||||
assertFileExists("build/bin/$nativeHostTargetName/mainDebugExecutable/$nativeExeName")
|
assertFileExists("build/bin/$nativeHostTargetName/mainDebugExecutable/$nativeExeName")
|
||||||
|
|
||||||
// Check that linker options was correctly passed to the K/N compiler.
|
// Check that linker options were correctly passed to the K/N compiler.
|
||||||
output.lineSequence().filter {
|
checkProgramCompilationCommandLine {
|
||||||
it.contains("Run tool: konanc") && it.contains("-p program")
|
|
||||||
}.toList().also {
|
|
||||||
assertTrue(it.isNotEmpty())
|
|
||||||
}.forEach {
|
|
||||||
assertTrue(it.contains("-linker-options -L."))
|
assertTrue(it.contains("-linker-options -L."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -30,6 +30,7 @@ kotlin {
|
|||||||
// Check that linker options are correctly passed to the compiler.
|
// Check that linker options are correctly passed to the compiler.
|
||||||
linkerOpts = mutableListOf("-L.")
|
linkerOpts = mutableListOf("-L.")
|
||||||
}
|
}
|
||||||
|
compilations["test"].linkerOpts = mutableListOf("-L.")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private fun test() {
|
||||||
|
println("test")
|
||||||
|
}
|
||||||
+1
@@ -68,6 +68,7 @@ kotlin {
|
|||||||
compilations.main.entryPoint = "com.example.app.native.main"
|
compilations.main.entryPoint = "com.example.app.native.main"
|
||||||
// Check that linker options are correctly passed to the compiler.
|
// Check that linker options are correctly passed to the compiler.
|
||||||
compilations.main.linkerOpts = ['-L.']
|
compilations.main.linkerOpts = ['-L.']
|
||||||
|
compilations.test.linkerOpts = ['-L.']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private fun test() {
|
||||||
|
println("test")
|
||||||
|
}
|
||||||
+5
-1
@@ -134,7 +134,7 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
|||||||
internal fun defaultTestExecutable(
|
internal fun defaultTestExecutable(
|
||||||
configure: Executable.() -> Unit
|
configure: Executable.() -> Unit
|
||||||
) = createBinaries(
|
) = createBinaries(
|
||||||
"test",
|
DEFAULT_TEST_NAME_PREFIX,
|
||||||
"test",
|
"test",
|
||||||
NativeOutputKind.EXECUTABLE,
|
NativeOutputKind.EXECUTABLE,
|
||||||
listOf(DEFAULT_TEST_BUILD_TYPE),
|
listOf(DEFAULT_TEST_BUILD_TYPE),
|
||||||
@@ -144,8 +144,12 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
|||||||
configure
|
configure
|
||||||
)
|
)
|
||||||
|
|
||||||
|
internal fun getDefaultTestExecutable(): Executable =
|
||||||
|
getExecutable(DEFAULT_TEST_NAME_PREFIX, DEFAULT_TEST_BUILD_TYPE)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
internal val DEFAULT_TEST_BUILD_TYPE = NativeBuildType.DEBUG
|
internal val DEFAULT_TEST_BUILD_TYPE = NativeBuildType.DEBUG
|
||||||
|
internal val DEFAULT_TEST_NAME_PREFIX = "test"
|
||||||
|
|
||||||
internal fun generateBinaryName(prefix: String, buildType: NativeBuildType, outputKindClassifier: String) =
|
internal fun generateBinaryName(prefix: String, buildType: NativeBuildType, outputKindClassifier: String) =
|
||||||
lowerCamelCaseName(prefix, buildType.getName(), outputKindClassifier)
|
lowerCamelCaseName(prefix, buildType.getName(), outputKindClassifier)
|
||||||
|
|||||||
+5
@@ -664,6 +664,11 @@ open class KotlinNativeTargetConfigurator(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Allow setting linker options for the default test executable using the
|
||||||
|
// corresponding properties of the test compilation.
|
||||||
|
target.binaries.getDefaultTestExecutable().apply {
|
||||||
|
linkerOpts.addAll(target.compilations.getByName(TEST_COMPILATION_NAME).linkerOpts)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user