Gradle, native: Fix creating test binaries for non-host platforms
Issue #KT-31725 fixed
This commit is contained in:
+2
-2
@@ -163,7 +163,7 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
||||
|Probably you are accessing the default test binary using the 'binaries.getExecutable("$DEFAULT_TEST_NAME_PREFIX", ${DEFAULT_TEST_BUILD_TYPE.name})' method.
|
||||
|Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use:
|
||||
|
|
||||
| binaries.getTest(DEBUG)
|
||||
| binaries.getTest("DEBUG")
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
@@ -172,7 +172,7 @@ open class KotlinNativeBinaryContainer @Inject constructor(
|
||||
|Probably you are accessing the default test binary using the 'binaries.findExecutable("$DEFAULT_TEST_NAME_PREFIX", ${DEFAULT_TEST_BUILD_TYPE.name})' method.
|
||||
|Since 1.3.40 tests are represented by a separate binary type. To get the default test binary, use:
|
||||
|
|
||||
| binaries.findTest(DEBUG)
|
||||
| binaries.findTest("DEBUG")
|
||||
|
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
+19
-18
@@ -232,30 +232,31 @@ open class KotlinNativeTargetConfigurator(
|
||||
}
|
||||
|
||||
override fun configureTest(target: KotlinNativeTarget): Unit = with(target.project) {
|
||||
// We don't create test tasks for non-host platforms.
|
||||
if (target.konanTarget !in listOf(KonanTarget.MACOS_X64, KonanTarget.MINGW_X64, KonanTarget.LINUX_X64)) {
|
||||
return
|
||||
}
|
||||
|
||||
val taskName = lowerCamelCaseName(target.disambiguationClassifier, testTaskNameSuffix)
|
||||
// We create test binaries for all platforms.
|
||||
target.binaries.test(listOf(NativeBuildType.DEBUG)) {
|
||||
val testTask = createOrRegisterTask<KotlinNativeTest>(taskName) { testTask ->
|
||||
testTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
|
||||
testTask.description = "Executes Kotlin/Native unit tests for target ${target.name}."
|
||||
testTask.targetName = compilation.target.targetName
|
||||
|
||||
testTask.enabled = target.konanTarget.isCurrentHost
|
||||
// But run them only on host ones.
|
||||
if (target.konanTarget in listOf(KonanTarget.MACOS_X64, KonanTarget.MINGW_X64, KonanTarget.LINUX_X64)) {
|
||||
|
||||
testTask.executable { outputFile }
|
||||
testTask.workingDir = project.projectDir.absolutePath
|
||||
val taskName = lowerCamelCaseName(target.disambiguationClassifier, testTaskNameSuffix)
|
||||
val testTask = createOrRegisterTask<KotlinNativeTest>(taskName) { testTask ->
|
||||
testTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
|
||||
testTask.description = "Executes Kotlin/Native unit tests for target ${target.name}."
|
||||
testTask.targetName = compilation.target.targetName
|
||||
|
||||
testTask.onlyIf { outputFile.exists() }
|
||||
testTask.dependsOn(linkTaskName)
|
||||
testTask.enabled = target.konanTarget.isCurrentHost
|
||||
|
||||
testTask.configureConventions()
|
||||
testTask.executable { outputFile }
|
||||
testTask.workingDir = project.projectDir.absolutePath
|
||||
|
||||
testTask.onlyIf { outputFile.exists() }
|
||||
testTask.dependsOn(linkTaskName)
|
||||
|
||||
testTask.configureConventions()
|
||||
}
|
||||
|
||||
kotlinTestRegistry.registerTestTask(testTask)
|
||||
}
|
||||
|
||||
kotlinTestRegistry.registerTestTask(testTask)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user