MPP wizard tests: run Native tests using correct task name
This commit is contained in:
+1
-2
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.ide.konan.gradle
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinGradleAbstractMultiplatformModuleBuilder
|
||||
import org.jetbrains.kotlin.konan.target.presetName
|
||||
@@ -16,7 +15,7 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
|
||||
private val nativeTargetName = defaultNativeTarget.userTargetName
|
||||
|
||||
private val nativeSourceName get() = "$nativeTargetName$productionSuffix"
|
||||
private val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
|
||||
override fun getBuilderId() = "kotlin.gradle.multiplatform.native"
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ class KotlinGradleMobileSharedMultiplatformModuleBuilder : KotlinGradleAbstractM
|
||||
private val jvmSourceName get() = "$jvmTargetName$productionSuffix"
|
||||
private val jvmTestName get() = "$jvmTargetName$testSuffix"
|
||||
private val nativeSourceName get() = "$nativeTargetName$productionSuffix"
|
||||
private val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
|
||||
override val shouldEnableGradleMetadataPreview: Boolean = true
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class KotlinGradleSharedMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
|
||||
private val jsSourceName get() = "$jsTargetName$productionSuffix"
|
||||
private val jsTestName get() = "$jsTargetName$testSuffix"
|
||||
private val nativeSourceName get() = "$nativeTargetName$productionSuffix"
|
||||
private val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
val nativeTestName get() = "$nativeTargetName$testSuffix"
|
||||
|
||||
override val shouldEnableGradleMetadataPreview: Boolean = true
|
||||
|
||||
|
||||
+11
-2
@@ -84,7 +84,7 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
|
||||
vararg testClassNames: String,
|
||||
metadataInside: Boolean = false,
|
||||
performImport: Boolean = true
|
||||
) {
|
||||
): Project {
|
||||
// TODO: check whether it's necessary to have templates in sources
|
||||
// Temporary workaround for duplicated bundled template
|
||||
class PrintingFactory : Logger.Factory {
|
||||
@@ -132,11 +132,12 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
|
||||
val buildScriptText = StringUtil.convertLineSeparators(VfsUtilCore.loadText(buildScript))
|
||||
println(buildScriptText)
|
||||
|
||||
if (!performImport) return
|
||||
if (!performImport) return project
|
||||
doImportProject(project)
|
||||
if (testClassNames.isNotEmpty()) {
|
||||
doTestProject(project, *testClassNames)
|
||||
}
|
||||
return project
|
||||
}
|
||||
|
||||
private fun File.assertNoEmptyChildren() {
|
||||
@@ -242,6 +243,14 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
|
||||
}
|
||||
}
|
||||
|
||||
protected fun runTaskInProject(project: Project, taskName: String) {
|
||||
val settings = GradleExecutionSettings(null, null, DistributionType.DEFAULT_WRAPPED, false)
|
||||
println("Running project task: $taskName")
|
||||
GradleExecutionHelper().execute(project.basePath!!, settings) {
|
||||
it.newBuild().forTasks(taskName).run()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
val javaHome = IdeaTestUtil.requireRealJdkHome()
|
||||
|
||||
+13
-10
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.idea.configuration.KotlinGradleMobileMultiplatformMo
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinGradleMobileSharedMultiplatformModuleBuilder
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinGradleSharedMultiplatformModuleBuilder
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinGradleWebMultiplatformModuleBuilder
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.junit.Test
|
||||
|
||||
class GradleMultiplatformWizardTest : AbstractGradleMultiplatformWizardTest() {
|
||||
@@ -21,24 +22,26 @@ class GradleMultiplatformWizardTest : AbstractGradleMultiplatformWizardTest() {
|
||||
|
||||
@Test
|
||||
fun testMobileShared() {
|
||||
testImportFromBuilder(
|
||||
KotlinGradleMobileSharedMultiplatformModuleBuilder(),
|
||||
"SampleTests", "SampleTestsJVM", "SampleTestsNative", metadataInside = true
|
||||
)
|
||||
val builder = KotlinGradleMobileSharedMultiplatformModuleBuilder()
|
||||
val project = testImportFromBuilder(builder, "SampleTests", "SampleTestsJVM", metadataInside = true)
|
||||
// Native tests can be run on Mac only
|
||||
if (HostManager.hostIsMac) {
|
||||
runTaskInProject(project, builder.nativeTestName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNative() {
|
||||
// TODO: add test run here (probably after fix of KT-27599)
|
||||
testImportFromBuilder(KotlinGradleNativeMultiplatformModuleBuilder())
|
||||
val builder = KotlinGradleNativeMultiplatformModuleBuilder()
|
||||
val project = testImportFromBuilder(builder)
|
||||
runTaskInProject(project, builder.nativeTestName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testShared() {
|
||||
testImportFromBuilder(
|
||||
KotlinGradleSharedMultiplatformModuleBuilder(),
|
||||
"SampleTests", "SampleTestsJVM", "SampleTestsNative", metadataInside = true
|
||||
)
|
||||
val builder = KotlinGradleSharedMultiplatformModuleBuilder()
|
||||
val project = testImportFromBuilder(builder, "SampleTests", "SampleTestsJVM", "SampleTestsNative", metadataInside = true)
|
||||
runTaskInProject(project, builder.nativeTestName)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ class GradleMultiplatformWizardTest : AbstractGradleMultiplatformWizardTest() {
|
||||
// NB: I'm not quite sure this thing really works in 181 (Native is inside)
|
||||
testImportFromBuilder(
|
||||
KotlinGradleSharedMultiplatformModuleBuilder(),
|
||||
"SampleTests", "SampleTestsJVM", "SampleTestsNative", metadataInside = true
|
||||
"SampleTests", "SampleTestsJVM", metadataInside = true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user