Test caches creation with turning incremental on/off
Original commit: 2bed8d0557
This commit is contained in:
@@ -447,12 +447,12 @@ public class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR
|
||||
incrementalCaches: Map<ModuleBuildTarget, IncrementalCacheImpl>,
|
||||
generatedFiles: List<GeneratedFile>
|
||||
): ChangesInfo {
|
||||
incrementalCaches.values().forEach { it.saveCacheFormatVersion() }
|
||||
|
||||
if (!IncrementalCompilation.isEnabled()) {
|
||||
return ChangesInfo.NO_CHANGES
|
||||
}
|
||||
|
||||
incrementalCaches.values().forEach { it.saveCacheFormatVersion() }
|
||||
|
||||
var changesInfo = ChangesInfo.NO_CHANGES
|
||||
for (generatedFile in generatedFiles) {
|
||||
val ic = incrementalCaches[generatedFile.target]!!
|
||||
|
||||
@@ -345,13 +345,13 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
val modifications = getModificationsToPerform(moduleNames)
|
||||
for (step in modifications) {
|
||||
step.forEach { it.perform(workDir) }
|
||||
performAdditionalModifications()
|
||||
performAdditionalModifications(step)
|
||||
results.add(make())
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
protected open fun performAdditionalModifications() {
|
||||
protected open fun performAdditionalModifications(modifications: List<Modification>) {
|
||||
}
|
||||
|
||||
// null means one module
|
||||
@@ -415,13 +415,13 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
}
|
||||
|
||||
private abstract class Modification(val path: String) {
|
||||
protected abstract class Modification(val path: String) {
|
||||
abstract fun perform(workDir: File)
|
||||
|
||||
override fun toString(): String = "${javaClass.simpleName} $path"
|
||||
}
|
||||
|
||||
private class ModifyContent(path: String, val dataFile: File) : Modification(path) {
|
||||
protected class ModifyContent(path: String, val dataFile: File) : Modification(path) {
|
||||
override fun perform(workDir: File) {
|
||||
val file = File(workDir, path)
|
||||
|
||||
@@ -437,7 +437,7 @@ public abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteFile(path: String) : Modification(path) {
|
||||
protected class DeleteFile(path: String) : Modification(path) {
|
||||
override fun perform(workDir: File) {
|
||||
val fileToDelete = File(workDir, path)
|
||||
if (!fileToDelete.delete()) {
|
||||
|
||||
+37
-4
@@ -26,11 +26,44 @@ import java.io.File
|
||||
|
||||
public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJpsTest() {
|
||||
override fun doTest(testDataPath: String) {
|
||||
super.doTest(testDataPath)
|
||||
try {
|
||||
super.doTest(testDataPath)
|
||||
|
||||
val actual = dumpKotlinCachesFileNames()
|
||||
val expectedFile = File(testDataPath, "expected-kotlin-caches.txt")
|
||||
UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual)
|
||||
val actual = dumpKotlinCachesFileNames()
|
||||
val expectedFile = File(testDataPath, "expected-kotlin-caches.txt")
|
||||
UsefulTestCase.assertSameLinesWithFile(expectedFile.canonicalPath, actual)
|
||||
}
|
||||
finally {
|
||||
IncrementalCompilation.enableIncrementalCompilation()
|
||||
}
|
||||
}
|
||||
|
||||
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
||||
super.performAdditionalModifications(modifications)
|
||||
|
||||
var modified = 0
|
||||
|
||||
for (modification in modifications) {
|
||||
if (!modification.path.endsWith("incremental_compilation_off")) continue
|
||||
|
||||
when (modification) {
|
||||
is AbstractIncrementalJpsTest.ModifyContent -> {
|
||||
IncrementalCompilation.disableIncrementalCompilation()
|
||||
}
|
||||
is AbstractIncrementalJpsTest.DeleteFile -> {
|
||||
IncrementalCompilation.enableIncrementalCompilation()
|
||||
}
|
||||
else -> {
|
||||
throw IllegalStateException("Unknown modification type: ${modification.javaClass}")
|
||||
}
|
||||
}
|
||||
|
||||
modified++
|
||||
}
|
||||
|
||||
if (modified > 1) {
|
||||
throw IllegalStateException("Incremental compilation was enabled/disable more than once")
|
||||
}
|
||||
}
|
||||
|
||||
private fun dumpKotlinCachesFileNames(): String {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class IncrementalCacheVersionChangedTest : AbstractIncrementalJpsTest(all
|
||||
doTest("jps-plugin/testData/incremental/custom/cacheVersionChangedMultiModule/")
|
||||
}
|
||||
|
||||
override fun performAdditionalModifications() {
|
||||
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
||||
val targets = projectDescriptor.allModuleTargets
|
||||
val paths = projectDescriptor.dataManager.dataPaths
|
||||
|
||||
|
||||
+12
@@ -53,6 +53,18 @@ public class IncrementalLazyCachesTestGenerated extends AbstractIncrementalLazyC
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incrementalCompilationOff")
|
||||
public void testIncrementalCompilationOff() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/incrementalCompilationOff/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("incrementalCompilationOffOn")
|
||||
public void testIncrementalCompilationOffOn() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/incrementalCompilationOffOn/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFunctionDeclared")
|
||||
public void testInlineFunctionDeclared() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("jps-plugin/testData/incremental/lazyKotlinCaches/inlineFunctionDeclared/");
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class IncrementalProjectPathCaseChangedTest : AbstractIncrementalJpsTest(
|
||||
super.doTest(testDataPath)
|
||||
}
|
||||
|
||||
override fun performAdditionalModifications() {
|
||||
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
||||
val module = myProject.getModules()[0]
|
||||
val sourceRoot = module.getSourceRoots()[0].getUrl()
|
||||
assert(sourceRoot.endsWith("/src"))
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
Cleaning output files:
|
||||
out/production/module1/module1/A.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module1/src/module1_a.kt
|
||||
module1/src/module1_other.kt
|
||||
End of files
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
module1->
|
||||
module2->module1
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Module 'module1' production
|
||||
Module 'module1' tests
|
||||
Module 'module2' production
|
||||
Module 'module2' tests
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package module1
|
||||
|
||||
class A
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package module1
|
||||
|
||||
class A
|
||||
|
||||
inline fun f() {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package module1
|
||||
|
||||
fun other() {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class B {
|
||||
void f() {
|
||||
new module1.A();
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
Cleaning output files:
|
||||
out/production/module1/module1/A.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module1/src/module1_a.kt
|
||||
module1/src/module1_other.kt
|
||||
End of files
|
||||
|
||||
|
||||
Cleaning output files:
|
||||
out/production/module1/META-INF/module1.kotlin_module
|
||||
out/production/module1/module1/A.class
|
||||
out/production/module1/module1/Module1Package.class
|
||||
out/production/module1/module1/Module1_aKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module1/src/module1_a.kt
|
||||
End of files
|
||||
Cleaning output files:
|
||||
out/production/module1/META-INF/module1.kotlin_module
|
||||
out/production/module1/module1/A.class
|
||||
out/production/module1/module1/Module1Package.class
|
||||
out/production/module1/module1/Module1_aKt.class
|
||||
out/production/module1/module1/Module1_otherKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module1/src/module1_a.kt
|
||||
module1/src/module1_other.kt
|
||||
End of files
|
||||
Cleaning output files:
|
||||
out/production/module2/B.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module2/src/module2_B.java
|
||||
End of files
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module1->
|
||||
module2->module1
|
||||
module3->
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
Module 'module1' production
|
||||
format-version.txt
|
||||
inline-functions.tab
|
||||
package-parts.tab
|
||||
proto.tab
|
||||
source-to-classes.tab
|
||||
Module 'module1' tests
|
||||
format-version.txt
|
||||
Module 'module2' production
|
||||
format-version.txt
|
||||
Module 'module2' tests
|
||||
Module 'module3' production
|
||||
format-version.txt
|
||||
package-parts.tab
|
||||
proto.tab
|
||||
source-to-classes.tab
|
||||
Module 'module3' tests
|
||||
format-version.txt
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package module1
|
||||
|
||||
class A
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package module1
|
||||
|
||||
class A
|
||||
|
||||
inline fun f() {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package module1
|
||||
|
||||
class A
|
||||
|
||||
inline fun f() {}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package module1
|
||||
|
||||
fun other() {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class B {
|
||||
void f() {
|
||||
new module1.A();
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package module3
|
||||
|
||||
fun c() {}
|
||||
Reference in New Issue
Block a user