Add test for 'isHMPP' flag
This commit is contained in:
@@ -213,6 +213,9 @@ private fun Module.computeLanguageVersionSettings(): LanguageVersionSettings {
|
||||
val Module.platform: TargetPlatform?
|
||||
get() = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this).targetPlatform ?: project.platform
|
||||
|
||||
val Module.isHMPPEnabled: Boolean
|
||||
get() = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this).isHmppEnabled
|
||||
|
||||
// FIXME(dsavvinov): this logic is clearly wrong in MPP environment; review and fix
|
||||
val Project.platform: TargetPlatform?
|
||||
get() {
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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
|
||||
|
||||
import org.jetbrains.kotlin.idea.codeInsight.gradle.MultiplePluginVersionGradleImportingTestCase
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class HierarchicalMultiplatformProjectImportingTest : MultiplePluginVersionGradleImportingTestCase() {
|
||||
//TODO support testing multiple gradle plugins versions
|
||||
|
||||
override fun isApplicableTest(): Boolean {
|
||||
return !gradleVersion.startsWith("3.")
|
||||
}
|
||||
|
||||
@Before
|
||||
fun saveSdksBeforeTest() {
|
||||
val kotlinSdks = sdkCreationChecker?.getKotlinSdks() ?: emptyList()
|
||||
if (kotlinSdks.isNotEmpty()) {
|
||||
fail("Found Kotlin SDK before importing test. Sdk list: $kotlinSdks")
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun checkSdkCreated() {
|
||||
if (sdkCreationChecker?.isKotlinSdkCreated() == false) {
|
||||
fail("Kotlin SDK was not created during import of HMPP Project.")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testImportHMPPFlag() {
|
||||
configureByFiles()
|
||||
importProject()
|
||||
|
||||
checkProjectStructure(exhaustiveModuleList = false, exhaustiveSourceSourceRootList = false, exhaustiveDependencyList = false) {
|
||||
allModules {
|
||||
isHMPP(true)
|
||||
}
|
||||
module("project.my-app.commonMain")
|
||||
module("project.my-app.jvmAndJsMain")
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkProjectStructure(
|
||||
exhaustiveModuleList: Boolean = true,
|
||||
exhaustiveSourceSourceRootList: Boolean = true,
|
||||
exhaustiveDependencyList: Boolean = true,
|
||||
body: ProjectInfo.() -> Unit = {}
|
||||
) {
|
||||
checkProjectStructure(
|
||||
myProject,
|
||||
projectPath,
|
||||
exhaustiveModuleList,
|
||||
exhaustiveSourceSourceRootList,
|
||||
exhaustiveDependencyList,
|
||||
body)
|
||||
}
|
||||
|
||||
override fun importProject() {
|
||||
val isUseQualifiedModuleNames = currentExternalProjectSettings.isUseQualifiedModuleNames
|
||||
currentExternalProjectSettings.isUseQualifiedModuleNames = true
|
||||
val isCreateEmptyContentRootDirectories = currentExternalProjectSettings.isCreateEmptyContentRootDirectories
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = true
|
||||
try {
|
||||
super.importProject()
|
||||
} finally {
|
||||
currentExternalProjectSettings.isCreateEmptyContentRootDirectories = isCreateEmptyContentRootDirectories
|
||||
currentExternalProjectSettings.isUseQualifiedModuleNames = isUseQualifiedModuleNames
|
||||
}
|
||||
}
|
||||
|
||||
override fun testDataDirName(): String {
|
||||
return "hierarchicalMultiplatformImport"
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType
|
||||
import org.jetbrains.jps.util.JpsPathUtil
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.project.isHMPPEnabled
|
||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||
import org.jetbrains.kotlin.idea.project.platform
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
@@ -103,6 +104,13 @@ class ModuleInfo(
|
||||
}
|
||||
}
|
||||
|
||||
fun isHMPP(value: Boolean) {
|
||||
val actualValue = module.isHMPPEnabled
|
||||
if (actualValue != value) {
|
||||
projectInfo.messageCollector.report("Module '${module.name}': expected isHMPP '$value' but found '$actualValue'")
|
||||
}
|
||||
}
|
||||
|
||||
fun apiVersion(version: String) {
|
||||
val actualVersion = module.languageVersionSettings.apiVersion.versionString
|
||||
if (actualVersion != version) {
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
plugins {
|
||||
// TODO parametrization
|
||||
kotlin("multiplatform").version("1.3.40-dev-1840")
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://kotlin.bintray.com/kotlin-dev")
|
||||
jcenter()
|
||||
}
|
||||
|
||||
group = "project"
|
||||
version = "1.0"
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
js()
|
||||
linuxX64()
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
}
|
||||
|
||||
val commonTest by getting {
|
||||
}
|
||||
|
||||
val jvmAndJsMain by creating {
|
||||
}
|
||||
|
||||
val jvmAndJsTest by creating {
|
||||
}
|
||||
|
||||
val linuxAndJsMain by creating {
|
||||
}
|
||||
|
||||
val linuxAndJsTest by creating {
|
||||
}
|
||||
|
||||
jvm().compilations["main"].defaultSourceSet {
|
||||
}
|
||||
|
||||
jvm().compilations["test"].defaultSourceSet {
|
||||
}
|
||||
|
||||
js().compilations["main"].defaultSourceSet {
|
||||
}
|
||||
|
||||
js().compilations["test"].defaultSourceSet {
|
||||
}
|
||||
|
||||
linuxX64().compilations["main"].defaultSourceSet {
|
||||
}
|
||||
|
||||
linuxX64().compilations["test"].defaultSourceSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "my-app"
|
||||
|
||||
enableFeaturePreview("GRADLE_METADATA")
|
||||
Reference in New Issue
Block a user