Skip to content

Commit

Permalink
HMPP: Fix serialization of TargetPlatform in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddolovov committed Apr 14, 2020
1 parent fee6a75 commit 753ef97
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="2" platform="Native " allPlatforms="Native []" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-version -Xallow-kotlin-package -Xskip-metadata-version-check" />
</compilerSettings>
<compilerArguments>
<option name="languageVersion" value="1.1" />
<option name="apiVersion" value="1.0" />
<option name="coroutinesEnable" value="true" />
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
<component name="CopyrightManager" default="" />
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="libraryTable">
<library name="KotlinJavaRuntime (2)">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../mockRuntime11/kotlin-runtime.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
</SOURCES>
</library>
</component>
</project>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}

0 comments on commit 753ef97

Please sign in to comment.