diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 6b0e4b01bbd..87dadc9f1b3 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -98,6 +98,7 @@ import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest import org.jetbrains.kotlin.jps.build.AbstractIncrementalJpsTest +import org.jetbrains.kotlin.jps.build.AbstractIncrementalLazyCachesTest import org.jetbrains.kotlin.jps.build.AbstractLookupTrackerTest import org.jetbrains.kotlin.jps.build.android.AbstractAndroidJpsTestCase import org.jetbrains.kotlin.jps.incremental.AbstractProtoComparisonTest @@ -835,6 +836,10 @@ fun main(args: Array) { testClass(javaClass()) { model("incremental/lookupTracker", extension = null, excludeParentDirs = true) } + + testClass(AbstractIncrementalLazyCachesTest::class.java) { + model("incremental/lazyKotlinCaches", extension = null, excludeParentDirs = true) + } } testGroup("jps-plugin/test", "jps-plugin/testData") { diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index 4d92ee1b445..8bfa18534b3 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -56,6 +56,9 @@ val INLINE_ANNOTATION_DESC = "Lkotlin/inline;" internal val CACHE_DIRECTORY_NAME = "kotlin" +@TestOnly +public fun getCacheDirectoryName(): String = + CACHE_DIRECTORY_NAME public class IncrementalCacheImpl( targetDataRoot: File, diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt new file mode 100644 index 00000000000..91e17db91ce --- /dev/null +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalLazyCachesTest.kt @@ -0,0 +1,62 @@ +/* + * 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.testFramework.UsefulTestCase +import org.jetbrains.kotlin.jps.incremental.IncrementalCacheImpl +import org.jetbrains.kotlin.jps.incremental.getCacheDirectoryName +import org.jetbrains.kotlin.utils.Printer +import java.io.File + +public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest() { + override fun doTest(testDataPath: String) { + super.doTest(testDataPath) + + val actual = dumpKotlinCachesFileNames() + val expectedFile = File(testDataPath, "expected-kotlin-caches.txt") + UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual) + } + + private fun dumpKotlinCachesFileNames(): String { + val sb = StringBuilder() + val p = Printer(sb) + val targets = projectDescriptor.allModuleTargets + val paths = projectDescriptor.dataManager.dataPaths + + for (target in targets.sortedBy { it.presentableName }) { + p.println(target) + p.pushIndent() + + val dataRoot = paths.getTargetDataRoot(target) + val cacheNames = kotlinCacheNames(dataRoot) + cacheNames.sorted().forEach { p.println(it) } + + p.popIndent() + } + + return sb.toString() + } + + private fun kotlinCacheNames(dataRoot: File): List { + val cacheDir = File(dataRoot, getCacheDirectoryName()) + val fileNames = cacheDir.list() ?: arrayOf() + val cacheFiles = fileNames + .map { File(cacheDir, it) } + .filter { it.isFile && it.extension == IncrementalCacheImpl.CACHE_EXTENSION } + return cacheFiles.map { it.name } + } +} \ No newline at end of file diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java b/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java new file mode 100644 index 00000000000..19d5ce2d25d --- /dev/null +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/IncrementalLazyCachesTestGenerated.java @@ -0,0 +1,74 @@ +/* + * 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.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.JetTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("jps-plugin/testData/incremental/lazyKotlinCaches") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IncrementalLazyCachesTestGenerated extends AbstractIncrementalLazyCachesTest { + public void testAllFilesPresentInLazyKotlinCaches() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/lazyKotlinCaches"), Pattern.compile("^([^\\.]+)$"), true); + } + + @TestMetadata("class") + public void testClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/class/"); + doTest(fileName); + } + + @TestMetadata("constant") + public void testConstant() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/constant/"); + doTest(fileName); + } + + @TestMetadata("function") + public void testFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/function/"); + doTest(fileName); + } + + @TestMetadata("inlineFunctionDeclared") + public void testInlineFunctionDeclared() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/"); + doTest(fileName); + } + + @TestMetadata("inlineFunctionInlined") + public void testInlineFunctionInlined() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/"); + doTest(fileName); + } + + @TestMetadata("noKotlin") + public void testNoKotlin() throws Exception { + String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/"); + doTest(fileName); + } + +} diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt new file mode 100644 index 00000000000..3dbcdef91ed --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt @@ -0,0 +1 @@ +public class A diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt.new b/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt.new new file mode 100644 index 00000000000..3dbcdef91ed --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/class/A.kt.new @@ -0,0 +1 @@ +public class A diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/class/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/class/build.log new file mode 100644 index 00000000000..8c01fa6b2e0 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/class/build.log @@ -0,0 +1,6 @@ +Cleaning output files: +out/production/module/A.class +End of files +Compiling files: +src/A.kt +End of files diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt new file mode 100644 index 00000000000..dbf1d85159b --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/class/expected-kotlin-caches.txt @@ -0,0 +1,4 @@ +Module 'module' production + proto.tab + source-to-classes.tab +Module 'module' tests diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/constant/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/build.log new file mode 100644 index 00000000000..2a2e5870c31 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/build.log @@ -0,0 +1,16 @@ +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/constant/ConstantKt.class +out/production/module/constant/ConstantPackage.class +End of files +Compiling files: +src/constant.kt +End of files +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/usage/UsageKt.class +out/production/module/usage/UsagePackage.class +End of files +Compiling files: +src/usage.kt +End of files \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt new file mode 100644 index 00000000000..5bb00251bf3 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt @@ -0,0 +1,3 @@ +package constant + +val X = 10 \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt.new b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt.new new file mode 100644 index 00000000000..922484aea23 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/constant.kt.new @@ -0,0 +1,3 @@ +package constant + +val X = 11 \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt new file mode 100644 index 00000000000..924694c447e --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/expected-kotlin-caches.txt @@ -0,0 +1,8 @@ +Module 'module' production + format-version.txt + constants.tab + package-parts.tab + proto.tab + source-to-classes.tab +Module 'module' tests + format-version.txt \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/constant/usage.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/usage.kt new file mode 100644 index 00000000000..4a70ee33065 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/constant/usage.kt @@ -0,0 +1,4 @@ +package usage + +fun f(): Int = + constant.X \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/function/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/function/build.log new file mode 100644 index 00000000000..2664e23862b --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/function/build.log @@ -0,0 +1,8 @@ +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/UtilsKt.class +out/production/module/_DefaultPackage.class +End of files +Compiling files: +src/utils.kt +End of files diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt new file mode 100644 index 00000000000..fbf6d51c660 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/function/expected-kotlin-caches.txt @@ -0,0 +1,5 @@ +Module 'module' production + package-parts.tab + proto.tab + source-to-classes.tab +Module 'module' tests diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt new file mode 100644 index 00000000000..7417787603f --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt @@ -0,0 +1 @@ +fun f() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt.new b/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt.new new file mode 100644 index 00000000000..7417787603f --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/function/utils.kt.new @@ -0,0 +1 @@ +fun f() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/build.log new file mode 100644 index 00000000000..003142b5452 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/build.log @@ -0,0 +1,8 @@ +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/inline/InlineKt.class +out/production/module/inline/InlinePackage.class +End of files +Compiling files: +src/inline.kt +End of files diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/expected-kotlin-caches.txt new file mode 100644 index 00000000000..33a2850ca0a --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/expected-kotlin-caches.txt @@ -0,0 +1,6 @@ +Module 'module' production + inline-functions.tab + package-parts.tab + proto.tab + source-to-classes.tab +Module 'module' tests diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt new file mode 100644 index 00000000000..406f6ee4388 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt @@ -0,0 +1,3 @@ +package inline + +inline fun f() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt.new b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt.new new file mode 100644 index 00000000000..406f6ee4388 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/inline.kt.new @@ -0,0 +1,3 @@ +package inline + +inline fun f() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/build.log new file mode 100644 index 00000000000..83bdd5a2da2 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/build.log @@ -0,0 +1,16 @@ +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/inline/InlineKt.class +out/production/module/inline/InlinePackage.class +End of files +Compiling files: +src/inline.kt +End of files +Cleaning output files: +out/production/module/META-INF/module.kotlin_module +out/production/module/usage/UsageKt.class +out/production/module/usage/UsagePackage.class +End of files +Compiling files: +src/usage.kt +End of files diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/expected-kotlin-caches.txt new file mode 100644 index 00000000000..fd3128f4651 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/expected-kotlin-caches.txt @@ -0,0 +1,7 @@ +Module 'module' production + inline-functions.tab + inlined-to.tab + package-parts.tab + proto.tab + source-to-classes.tab +Module 'module' tests diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt new file mode 100644 index 00000000000..406f6ee4388 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt @@ -0,0 +1,3 @@ +package inline + +inline fun f() {} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt.new b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt.new new file mode 100644 index 00000000000..1b69393d6eb --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/inline.kt.new @@ -0,0 +1,5 @@ +package inline + +inline fun f() { + println("changed") +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/usage.kt b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/usage.kt new file mode 100644 index 00000000000..4e9d8fe8eb2 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionInlined/usage.kt @@ -0,0 +1,5 @@ +package usage + +inline fun use() { + inline.f() +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java new file mode 100644 index 00000000000..61ff2abcc95 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java @@ -0,0 +1,2 @@ +public class A { +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java.new b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java.new new file mode 100644 index 00000000000..61ff2abcc95 --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/A.java.new @@ -0,0 +1,2 @@ +public class A { +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/build.log b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/build.log new file mode 100644 index 00000000000..b97f58152ee --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/build.log @@ -0,0 +1,6 @@ +Cleaning output files: +out/production/module/A.class +End of files +Compiling files: +src/A.java +End of files diff --git a/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/expected-kotlin-caches.txt b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/expected-kotlin-caches.txt new file mode 100644 index 00000000000..ce3849d63ef --- /dev/null +++ b/jps-plugin/testData/incremental/lazyKotlinCaches/noKotlin/expected-kotlin-caches.txt @@ -0,0 +1,2 @@ +Module 'module' production +Module 'module' tests \ No newline at end of file