Test that Kotlin incremental caches are created lazily
This commit is contained in:
@@ -98,6 +98,7 @@ import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest
|
|||||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
||||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
||||||
import org.jetbrains.kotlin.jps.build.AbstractIncrementalJpsTest
|
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.AbstractLookupTrackerTest
|
||||||
import org.jetbrains.kotlin.jps.build.android.AbstractAndroidJpsTestCase
|
import org.jetbrains.kotlin.jps.build.android.AbstractAndroidJpsTestCase
|
||||||
import org.jetbrains.kotlin.jps.incremental.AbstractProtoComparisonTest
|
import org.jetbrains.kotlin.jps.incremental.AbstractProtoComparisonTest
|
||||||
@@ -835,6 +836,10 @@ fun main(args: Array<String>) {
|
|||||||
testClass(javaClass<AbstractLookupTrackerTest>()) {
|
testClass(javaClass<AbstractLookupTrackerTest>()) {
|
||||||
model("incremental/lookupTracker", extension = null, excludeParentDirs = true)
|
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") {
|
testGroup("jps-plugin/test", "jps-plugin/testData") {
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ val INLINE_ANNOTATION_DESC = "Lkotlin/inline;"
|
|||||||
|
|
||||||
internal val CACHE_DIRECTORY_NAME = "kotlin"
|
internal val CACHE_DIRECTORY_NAME = "kotlin"
|
||||||
|
|
||||||
|
@TestOnly
|
||||||
|
public fun getCacheDirectoryName(): String =
|
||||||
|
CACHE_DIRECTORY_NAME
|
||||||
|
|
||||||
public class IncrementalCacheImpl(
|
public class IncrementalCacheImpl(
|
||||||
targetDataRoot: File,
|
targetDataRoot: File,
|
||||||
|
|||||||
@@ -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<String> {
|
||||||
|
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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
+74
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
public class A
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
public class A
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Cleaning output files:
|
||||||
|
out/production/module/A.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/A.kt
|
||||||
|
End of files
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
Module 'module' production
|
||||||
|
proto.tab
|
||||||
|
source-to-classes.tab
|
||||||
|
Module 'module' tests
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
val X = 10
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
val X = 11
|
||||||
+8
@@ -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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package usage
|
||||||
|
|
||||||
|
fun f(): Int =
|
||||||
|
constant.X
|
||||||
@@ -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
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
Module 'module' production
|
||||||
|
package-parts.tab
|
||||||
|
proto.tab
|
||||||
|
source-to-classes.tab
|
||||||
|
Module 'module' tests
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fun f() {}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
fun f() {}
|
||||||
+8
@@ -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
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
Module 'module' production
|
||||||
|
inline-functions.tab
|
||||||
|
package-parts.tab
|
||||||
|
proto.tab
|
||||||
|
source-to-classes.tab
|
||||||
|
Module 'module' tests
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package inline
|
||||||
|
|
||||||
|
inline fun f() {}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package inline
|
||||||
|
|
||||||
|
inline fun f() {}
|
||||||
+16
@@ -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
|
||||||
Vendored
+7
@@ -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
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package inline
|
||||||
|
|
||||||
|
inline fun f() {}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package inline
|
||||||
|
|
||||||
|
inline fun f() {
|
||||||
|
println("changed")
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package usage
|
||||||
|
|
||||||
|
inline fun use() {
|
||||||
|
inline.f()
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
public class A {
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
public class A {
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
Cleaning output files:
|
||||||
|
out/production/module/A.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
src/A.java
|
||||||
|
End of files
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
Module 'module' production
|
||||||
|
Module 'module' tests
|
||||||
Reference in New Issue
Block a user