diff --git a/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml b/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml new file mode 100644 index 0000000000000..1bb831be9cccf --- /dev/null +++ b/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/loadAndSaveOldNativeFacet/projectFile.ipr b/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/projectFile.ipr similarity index 100% rename from idea/testData/configuration/loadAndSaveOldNativeFacet/projectFile.ipr rename to idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/projectFile.ipr diff --git a/idea/testData/configuration/loadAndSaveOldNativeFacet/src/foo.kt b/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/src/foo.kt similarity index 100% rename from idea/testData/configuration/loadAndSaveOldNativeFacet/src/foo.kt rename to idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/src/foo.kt diff --git a/idea/testData/configuration/loadAndSaveOldNativeFacet/module.iml b/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/module.iml similarity index 100% rename from idea/testData/configuration/loadAndSaveOldNativeFacet/module.iml rename to idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/module.iml diff --git a/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/projectFile.ipr b/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/projectFile.ipr new file mode 100644 index 0000000000000..a1407e2c8cd3c --- /dev/null +++ b/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/projectFile.ipr @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/src/foo.kt b/idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/src/foo.kt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt index 3d5b530dd0e87..78d3de4d1c394 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt @@ -107,43 +107,26 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() } - fun testLoadAndSaveOldNativeFacet() { - val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray()) - val application = ApplicationManager.getApplication() as ApplicationImpl - application.isSaveAllowed = true - application.saveAll() - val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray()) - Assert.assertEquals( - moduleFileContentBefore.replace("platform=\"Native \"", "platform=\"Native \" allPlatforms=\"Native []\""), - moduleFileContentAfter - ) - } + fun testLoadAndSaveOldNativePlatformOldNativeFacet() = doTestLoadAndSaveProjectWithFacetConfig( + "platform=\"Native \"", + "platform=\"Native (general) \" allPlatforms=\"Native [general]\"" + ) - //TODO(auskov): test parsing common target platform with multiple versions of java, add parsing common platforms - fun testLoadAndSaveProjectWithV2OldPlatformFacetConfig() { - val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray()) - val application = ApplicationManager.getApplication() as ApplicationImpl - application.isSaveAllowed = true - application.saveAll() - val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray()) - Assert.assertEquals( - moduleFileContentBefore.replace("platform=\"JVM 1.8\"", "platform=\"JVM 1.8\" allPlatforms=\"JVM [1.8]\""), - moduleFileContentAfter - ) - } + fun testLoadAndSaveOldNativePlatformNewNativeFacet() = doTestLoadAndSaveProjectWithFacetConfig( + "platform=\"Native \" allPlatforms=\"Native []\"", + "platform=\"Native (general) \" allPlatforms=\"Native [general]\"" + ) - fun testLoadAndSaveProjectHMPPFacetConfig() { - val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray()) - val application = ApplicationManager.getApplication() as ApplicationImpl - application.isSaveAllowed = true - application.saveAll() - val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray()) - Assert.assertEquals( - moduleFileContentBefore.replace("platform=\"JVM 1.8\"", "platform=\"JVM 1.8\" allPlatforms=\"JVM [1.8]\""), - moduleFileContentAfter - ) - } + //TODO(auskov): test parsing common target platform with multiple versions of java, add parsing common platforms + fun testLoadAndSaveProjectWithV2OldPlatformFacetConfig() = doTestLoadAndSaveProjectWithFacetConfig( + "platform=\"JVM 1.8\"", + "platform=\"JVM 1.8\" allPlatforms=\"JVM [1.8]\"" + ) + fun testLoadAndSaveProjectHMPPFacetConfig() = doTestLoadAndSaveProjectWithFacetConfig( + "platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\"", + "platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native [general]\"" + ) fun testApiVersionWithoutLanguageVersion() { KotlinCommonCompilerArgumentsHolder.getInstance(myProject) @@ -161,4 +144,14 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() application.saveAll() Assert.assertTrue(project.baseDir.findFileByRelativePath(".idea/kotlinc.xml") == null) } + + private fun doTestLoadAndSaveProjectWithFacetConfig(valueBefore: String, valueAfter: String) { + val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray()) + Assert.assertTrue(moduleFileContentBefore.contains(valueBefore)) + val application = ApplicationManager.getApplication() as ApplicationImpl + application.isSaveAllowed = true + application.saveAll() + val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray()) + Assert.assertEquals(moduleFileContentBefore.replace(valueBefore, valueAfter), moduleFileContentAfter) + } }