Do not expose paths with placeholders in JS IC caches

#KT-31310 Fixed

Original commit: 209a5d8464
This commit is contained in:
Alexey Tsvetkov
2019-05-15 19:01:52 +03:00
parent 36580d46da
commit b5741d3120
7 changed files with 59 additions and 1 deletions
@@ -752,7 +752,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
}
private fun checkOutputFilesList(outputDir: File = productionOutputDir) {
protected fun checkOutputFilesList(outputDir: File = productionOutputDir) {
if (!expectedOutputFile.exists()) {
expectedOutputFile.writeText("")
throw IllegalStateException("$expectedOutputFile did not exist. Created empty file.")
@@ -36,18 +36,35 @@ import java.io.File
class KotlinJpsBuildTestIncremental : KotlinJpsBuildTest() {
var isICEnabledBackup: Boolean = false
var isICEnabledForJsBackup: Boolean = false
override fun setUp() {
super.setUp()
isICEnabledBackup = IncrementalCompilation.isEnabledForJvm()
IncrementalCompilation.setIsEnabledForJvm(true)
isICEnabledForJsBackup = IncrementalCompilation.isEnabledForJs()
IncrementalCompilation.setIsEnabledForJs(true)
}
override fun tearDown() {
IncrementalCompilation.setIsEnabledForJvm(isICEnabledBackup)
IncrementalCompilation.setIsEnabledForJs(isICEnabledForJsBackup)
super.tearDown()
}
fun testKotlinJavaScriptChangePackage() {
initProject(LibraryDependency.JS_STDLIB)
buildAllModules().assertSuccessful()
val class2Kt = File(workDir, "src/Class2.kt")
val newClass2KtContent = class2Kt.readText().replace("package2", "package1")
JpsBuildTestCase.change(class2Kt.path, newClass2KtContent)
buildAllModules().assertSuccessful()
checkOutputFilesList(File(workDir, "out/production"))
}
fun testRelocatableCaches() {
fun buildAndGetMappings(): String {
workDir.deleteRecursively()
@@ -0,0 +1,9 @@
kotlinProject/
kotlinProject/
package1/
package1.kjsm
kotlinProject.js
kotlinProject.meta.js
lib/
kotlin.js
kotlin.meta.js
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<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="IDEA_JDK" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="kotlinProject" />
</component>
</module>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
@@ -0,0 +1,3 @@
package package1
class Class1
@@ -0,0 +1,3 @@
package package2
class Class2