From e352af9bb8c59d8c2a4e1964994c2490b96bbfa3 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Mon, 8 Jun 2015 17:47:52 +0300 Subject: [PATCH] Fixed sticking of incremental cache data when case of file path is changed. Original commit: 959364aa77880a6c43d751fbf5fbdda733499a0d --- .../jps/incremental/IncrementalCacheImpl.kt | 3 +- .../jps/build/AbstractIncrementalJpsTest.kt | 12 ++++- .../IncrementalProjectPathCaseChangedTest.kt | 46 +++++++++++++++++++ .../custom/projectPathCaseChanged/build.log | 7 +++ .../custom/projectPathCaseChanged/foo.kt | 2 + .../custom/projectPathCaseChanged/foo.kt.new | 2 + 6 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt create mode 100644 jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/build.log create mode 100644 jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt create mode 100644 jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt.new diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index d300068fb41..106613c6d7b 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -46,6 +46,7 @@ import org.jetbrains.jps.builders.storage.BuildDataPaths import com.intellij.util.io.BooleanDataDescriptor import java.util.ArrayList import org.jetbrains.annotations.TestOnly +import org.jetbrains.jps.incremental.storage.PathStringDescriptor import org.jetbrains.kotlin.utils.Printer import java.io.DataInputStream @@ -546,7 +547,7 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen private inner class SourceToClassesMap : BasicMap>() { override fun createMap(): PersistentHashMap> = PersistentHashMap( File(baseDir, SOURCE_TO_CLASSES), - EnumeratorStringDescriptor(), + PathStringDescriptor.INSTANCE, StringListExternalizer ) diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index ca2e060bf93..fc3b4992bf3 100644 --- a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -79,6 +79,9 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver? get() = null + protected open val checkDumpsCaseInsensitively: Boolean + get() = false + fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().all()): MakeResult { val workDirPath = FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) val logger = MyLogger(workDirPath) @@ -190,7 +193,12 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { assertEqualDirectories(outDir, outAfterMake, makeOverallResult.makeFailed) if (!makeOverallResult.makeFailed) { - TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump) + if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) { + // do nothing + } + else { + TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump) + } } FileUtil.delete(outAfterMake) @@ -219,7 +227,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { return result } - protected fun doTest(testDataPath: String) { + protected open fun doTest(testDataPath: String) { testDataDir = File(testDataPath) workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "jps-build", null) diff --git a/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt new file mode 100644 index 00000000000..9a7d734a87e --- /dev/null +++ b/jps/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalProjectPathCaseChangedTest.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jps.build + +import com.intellij.openapi.util.SystemInfoRt +import org.jetbrains.jps.model.java.JavaSourceRootType + +public class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest() { + fun testProjectPathCaseChanged() { + doTest("jps-plugin/testData/incremental/custom/projectPathCaseChanged/") + } + + override fun doTest(testDataPath: String) { + if (SystemInfoRt.isFileSystemCaseSensitive) { + return + } + + super.doTest(testDataPath) + } + + override val checkDumpsCaseInsensitively: Boolean + get() = true + + override fun performAdditionalModifications() { + val module = myProject.getModules()[0] + val sourceRoot = module.getSourceRoots()[0].getUrl() + assert(sourceRoot.endsWith("/src")) + val newSourceRoot = sourceRoot.replace("/src", "/SRC") + module.removeSourceRoot(sourceRoot, JavaSourceRootType.SOURCE) + module.addSourceRoot(newSourceRoot, JavaSourceRootType.SOURCE) + } +} diff --git a/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/build.log b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/build.log new file mode 100644 index 00000000000..4cf233bbc00 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/build.log @@ -0,0 +1,7 @@ +Cleaning output files: +out/production/module/_DefaultPackage$foo$*.class +out/production/module/_DefaultPackage.class +End of files +Compiling files: +src/foo.kt +End of files \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt new file mode 100644 index 00000000000..99cec0dbea1 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt @@ -0,0 +1,2 @@ +fun f() { +} \ No newline at end of file diff --git a/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt.new b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt.new new file mode 100644 index 00000000000..99cec0dbea1 --- /dev/null +++ b/jps/jps-plugin/testData/incremental/custom/projectPathCaseChanged/foo.kt.new @@ -0,0 +1,2 @@ +fun f() { +} \ No newline at end of file