From 753ef971f995d71e44550e8074821de46579f9e8 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Mon, 13 Apr 2020 11:32:06 +0700 Subject: [PATCH] HMPP: Fix serialization of TargetPlatform in tests --- .../module.iml | 26 ++++++++ .../projectFile.ipr | 0 .../src/foo.kt | 0 .../module.iml | 0 .../projectFile.ipr | 41 +++++++++++++ .../src/foo.kt | 0 .../ConfigureKotlinInTempDirTest.kt | 61 ++++++++----------- 7 files changed, 94 insertions(+), 34 deletions(-) create mode 100644 idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml rename idea/testData/configuration/{loadAndSaveOldNativeFacet => loadAndSaveOldNativePlatformNewNativeFacet}/projectFile.ipr (100%) rename idea/testData/configuration/{loadAndSaveOldNativeFacet => loadAndSaveOldNativePlatformNewNativeFacet}/src/foo.kt (100%) rename idea/testData/configuration/{loadAndSaveOldNativeFacet => loadAndSaveOldNativePlatformOldNativeFacet}/module.iml (100%) create mode 100644 idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/projectFile.ipr create mode 100644 idea/testData/configuration/loadAndSaveOldNativePlatformOldNativeFacet/src/foo.kt diff --git a/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml b/idea/testData/configuration/loadAndSaveOldNativePlatformNewNativeFacet/module.iml new file mode 100644 index 00000000000..1bb831be9cc --- /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 00000000000..a1407e2c8cd --- /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 00000000000..e69de29bb2d diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinInTempDirTest.kt index 3d5b530dd0e..78d3de4d1c3 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]\"" + ) + + fun testLoadAndSaveOldNativePlatformNewNativeFacet() = doTestLoadAndSaveProjectWithFacetConfig( + "platform=\"Native \" allPlatforms=\"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 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 - ) - } + 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) + } }