[Gradle] Implement AppleSiliconIT
^KT-45302
This commit is contained in:
committed by
Space
parent
242d79ded6
commit
cc571a876a
+123
@@ -0,0 +1,123 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 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.gradle.native
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||||
|
import org.jetbrains.kotlin.gradle.GradleVersionRequired
|
||||||
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
|
import org.junit.Assume.assumeTrue
|
||||||
|
import org.junit.Test
|
||||||
|
import kotlin.test.BeforeTest
|
||||||
|
import kotlin.test.fail
|
||||||
|
|
||||||
|
class AppleSiliconIT : BaseGradleIT() {
|
||||||
|
override val defaultGradleVersion: GradleVersionRequired = GradleVersionRequired.FOR_MPP_SUPPORT
|
||||||
|
|
||||||
|
private val host = HostManager.host
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
fun assumeMacosHost() {
|
||||||
|
assumeTrue("Test requires MacOS host", HostManager.hostIsMac)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test compilation`() {
|
||||||
|
with(Project("appleSilicon")) {
|
||||||
|
build("assemble") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlinIosArm64",
|
||||||
|
":compileKotlinIosSimulatorArm64",
|
||||||
|
":compileKotlinIosX64",
|
||||||
|
":compileKotlinMacosArm64",
|
||||||
|
":compileKotlinMacosX64",
|
||||||
|
":compileKotlinTvosArm64",
|
||||||
|
":compileKotlinTvosSimulatorArm64",
|
||||||
|
":compileKotlinTvosX64",
|
||||||
|
":compileKotlinWatchosArm32",
|
||||||
|
":compileKotlinWatchosArm64",
|
||||||
|
":compileKotlinWatchosSimulatorArm64",
|
||||||
|
":compileKotlinWatchosX64",
|
||||||
|
":compileKotlinJvm",
|
||||||
|
":jvmJar",
|
||||||
|
":linkDebugExecutableMacosArm64",
|
||||||
|
":linkDebugExecutableMacosX64",
|
||||||
|
":linkReleaseExecutableMacosArm64",
|
||||||
|
":linkReleaseExecutableMacosX64",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test execution`() {
|
||||||
|
with(Project("appleSilicon")) {
|
||||||
|
build("check") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(":jvmTest")
|
||||||
|
assertContains("Executed Code from: commonMain/jvmMain")
|
||||||
|
|
||||||
|
val armTestOutputs = listOf(
|
||||||
|
"commonMain/iosMain/iosSimulatorArm64Main",
|
||||||
|
"commonMain/macosMain/macosArm64Main",
|
||||||
|
"commonMain/tvosMain/tvosSimulatorArm64Main",
|
||||||
|
"commonMain/watchosMain/watchosSimulatorArm64Main"
|
||||||
|
).map { "Executed Code from: $it" }
|
||||||
|
|
||||||
|
val x64TestOutputs = listOf(
|
||||||
|
"commonMain/iosMain/iosX64Main",
|
||||||
|
"commonMain/macosMain/macosX64Main",
|
||||||
|
"commonMain/tvosMain/tvosX64Main",
|
||||||
|
"commonMain/watchosMain/watchosX64Main"
|
||||||
|
).map { "Executed Code from: $it" }
|
||||||
|
|
||||||
|
when (host) {
|
||||||
|
KonanTarget.MACOS_ARM64 -> {
|
||||||
|
assertContains(*armTestOutputs.toTypedArray())
|
||||||
|
assertNotContains(*x64TestOutputs.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
KonanTarget.MACOS_X64 -> {
|
||||||
|
assertContains(*x64TestOutputs.toTypedArray())
|
||||||
|
assertNotContains(*armTestOutputs.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> fail("Unexpected host $host")
|
||||||
|
}
|
||||||
|
|
||||||
|
val armTests = listOf(
|
||||||
|
":iosSimulatorArm64Test",
|
||||||
|
":macosArm64Test",
|
||||||
|
":tvosSimulatorArm64Test",
|
||||||
|
":watchosSimulatorArm64Test",
|
||||||
|
)
|
||||||
|
|
||||||
|
val x64Tests = listOf(
|
||||||
|
":iosX64Test",
|
||||||
|
":jvmTest",
|
||||||
|
":macosX64Test",
|
||||||
|
":tvosX64Test",
|
||||||
|
":watchosX64Test",
|
||||||
|
)
|
||||||
|
|
||||||
|
when (host) {
|
||||||
|
KonanTarget.MACOS_ARM64 -> {
|
||||||
|
assertTasksExecuted(armTests)
|
||||||
|
assertTasksNotExecuted(x64Tests)
|
||||||
|
}
|
||||||
|
|
||||||
|
KonanTarget.MACOS_X64 -> {
|
||||||
|
assertTasksExecuted(x64Tests)
|
||||||
|
assertTasksNotExecuted(armTests)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> fail("Unexpected host $host")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
ios()
|
||||||
|
watchos()
|
||||||
|
tvos()
|
||||||
|
macos {
|
||||||
|
binaries.executable {
|
||||||
|
entryPoint = "main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val commonTest by sourceSets.getting
|
||||||
|
val jvmTest by sourceSets.getting
|
||||||
|
|
||||||
|
commonTest.dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
}
|
||||||
|
|
||||||
|
jvmTest.dependencies {
|
||||||
|
implementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<AbstractTestTask>().configureEach {
|
||||||
|
testLogging {
|
||||||
|
showStandardStreams = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
kotlin.code.style=official
|
||||||
|
kotlin.js.generate.executable.default=false
|
||||||
|
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||||
|
kotlin.native.enableDependencyPropagation=false
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
val kotlin_version: String by settings
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform").version(kotlin_version)
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun main() {
|
||||||
|
println("Executed Code from: commonMain/$sourceSetsAfterCommonMain")
|
||||||
|
}
|
||||||
|
|
||||||
|
expect val sourceSetsAfterCommonMain: String
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class MainTest {
|
||||||
|
@Test
|
||||||
|
fun run() {
|
||||||
|
main()
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterIosMain: String = "iosArm64"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
actual val sourceSetsAfterCommonMain get() = "iosMain/$sourceSetsAfterIosMain"
|
||||||
|
|
||||||
|
expect val sourceSetsAfterIosMain: String
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterIosMain: String = "iosSimulatorArm64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterIosMain: String = "iosX64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterCommonMain = "jvmMain"
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
actual val sourceSetsAfterMacosMain: String
|
||||||
|
get() = "macosArm64Main"
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
actual val sourceSetsAfterCommonMain get() = "macosMain/$sourceSetsAfterMacosMain"
|
||||||
|
|
||||||
|
expect val sourceSetsAfterMacosMain: String
|
||||||
|
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
actual val sourceSetsAfterMacosMain: String
|
||||||
|
get() = "macosX64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterTvOsMain: String = "tvosArm64Main"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
actual val sourceSetsAfterCommonMain get() = "tvosMain/$sourceSetsAfterTvOsMain"
|
||||||
|
|
||||||
|
expect val sourceSetsAfterTvOsMain: String
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterTvOsMain: String = "tvosSimulatorArm64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterTvOsMain: String = "tvosX64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterWatchosMain: String = "watchosArm32Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterWatchosMain: String = "watchosArm64Main"
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
actual val sourceSetsAfterCommonMain get() = "watchosMain/$sourceSetsAfterWatchosMain"
|
||||||
|
|
||||||
|
expect val sourceSetsAfterWatchosMain: String
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterWatchosMain: String = "watchosSimulatorArm64Main"
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
actual val sourceSetsAfterWatchosMain: String = "watchosX64Main"
|
||||||
Reference in New Issue
Block a user