Kotlin incremental cache version change should not affect java only modules
This commit is contained in:
+14
-4
@@ -21,10 +21,20 @@ import org.jetbrains.kotlin.jps.incremental.CacheVersionProvider
|
||||
|
||||
abstract class AbstractIncrementalCacheVersionChangedTest : AbstractIncrementalJpsTest(allowNoFilesWithSuffixInTestData = true) {
|
||||
override fun performAdditionalModifications(modifications: List<AbstractIncrementalJpsTest.Modification>) {
|
||||
val cacheVersionProvider = CacheVersionProvider(projectDescriptor.dataManager.dataPaths)
|
||||
val versions = getVersions(cacheVersionProvider, projectDescriptor.allModuleTargets)
|
||||
val versionFiles = versions.map { it.formatVersionFile }.filter { it.exists() }
|
||||
versionFiles.forEach { it.writeText("777") }
|
||||
val modifiedFiles = modifications.filterIsInstance<ModifyContent>().map { it.path }
|
||||
val paths = projectDescriptor.dataManager.dataPaths
|
||||
val targets = projectDescriptor.allModuleTargets
|
||||
|
||||
if (modifiedFiles.any { it.endsWith("clear-has-kotlin") }) {
|
||||
targets.forEach { KotlinBuilder.clearHasKotlin(it, paths) }
|
||||
}
|
||||
|
||||
if (modifiedFiles.none { it.endsWith("do-not-change-cache-versions") }) {
|
||||
val cacheVersionProvider = CacheVersionProvider(paths)
|
||||
val versions = getVersions(cacheVersionProvider, targets)
|
||||
val versionFiles = versions.map { it.formatVersionFile }.filter { it.exists() }
|
||||
versionFiles.forEach { it.writeText("777") }
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getVersions(cacheVersionProvider: CacheVersionProvider, targets: Iterable<ModuleBuildTarget>) =
|
||||
|
||||
@@ -51,8 +51,10 @@ public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJps
|
||||
for (modification in modifications) {
|
||||
if (modification !is AbstractIncrementalJpsTest.ModifyContent) continue
|
||||
|
||||
when (File(modification.path).name) {
|
||||
"incremental-compilation" -> {
|
||||
val name = File(modification.path).name
|
||||
|
||||
when {
|
||||
name.endsWith("incremental-compilation") -> {
|
||||
if (modification.dataFile.readAsBool()) {
|
||||
IncrementalCompilation.enableIncrementalCompilation()
|
||||
}
|
||||
@@ -60,7 +62,7 @@ public abstract class AbstractIncrementalLazyCachesTest : AbstractIncrementalJps
|
||||
IncrementalCompilation.disableIncrementalCompilation()
|
||||
}
|
||||
}
|
||||
"experimental-compilation" -> {
|
||||
name.endsWith("experimental-compilation") -> {
|
||||
if (modification.dataFile.readAsBool()) {
|
||||
IncrementalCompilation.enableExperimental()
|
||||
}
|
||||
|
||||
+24
@@ -35,12 +35,24 @@ public class DataContainerVersionChangedTestGenerated extends AbstractDataContai
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged"), Pattern.compile("^([^\\.]+)$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("clearedHasKotlin")
|
||||
public void testClearedHasKotlin() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("exportedModule")
|
||||
public void testExportedModule() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaOnlyModulesAreNotAffected")
|
||||
public void testJavaOnlyModulesAreNotAffected() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("module1Modified")
|
||||
public void testModule1Modified() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/");
|
||||
@@ -71,10 +83,22 @@ public class DataContainerVersionChangedTestGenerated extends AbstractDataContai
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("touchedOnlyJavaFile")
|
||||
public void testTouchedOnlyJavaFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("untouchedFiles")
|
||||
public void testUntouchedFiles() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withError")
|
||||
public void testWithError() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/withError/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -41,6 +41,18 @@ public class ExperimentalChangeIncrementalOptionTestGenerated extends AbstractEx
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("experimentalOnJavaChanged")
|
||||
public void testExperimentalOnJavaChanged() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnJavaChanged/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("experimentalOnJavaOnly")
|
||||
public void testExperimentalOnJavaOnly() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnJavaOnly/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("experimentalOnOff")
|
||||
public void testExperimentalOnOff() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/changeIncrementalOption/experimentalOnOff/");
|
||||
|
||||
+24
@@ -35,12 +35,24 @@ public class ExperimentalIncrementalCacheVersionChangedTestGenerated extends Abs
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged"), Pattern.compile("^([^\\.]+)$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("clearedHasKotlin")
|
||||
public void testClearedHasKotlin() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("exportedModule")
|
||||
public void testExportedModule() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaOnlyModulesAreNotAffected")
|
||||
public void testJavaOnlyModulesAreNotAffected() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("module1Modified")
|
||||
public void testModule1Modified() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/");
|
||||
@@ -71,10 +83,22 @@ public class ExperimentalIncrementalCacheVersionChangedTestGenerated extends Abs
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("touchedOnlyJavaFile")
|
||||
public void testTouchedOnlyJavaFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("untouchedFiles")
|
||||
public void testUntouchedFiles() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withError")
|
||||
public void testWithError() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/withError/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
@@ -35,12 +35,24 @@ public class IncrementalCacheVersionChangedTestGenerated extends AbstractIncreme
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/cacheVersionChanged"), Pattern.compile("^([^\\.]+)$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("clearedHasKotlin")
|
||||
public void testClearedHasKotlin() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/clearedHasKotlin/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("exportedModule")
|
||||
public void testExportedModule() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/exportedModule/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaOnlyModulesAreNotAffected")
|
||||
public void testJavaOnlyModulesAreNotAffected() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/javaOnlyModulesAreNotAffected/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("module1Modified")
|
||||
public void testModule1Modified() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/module1Modified/");
|
||||
@@ -71,10 +83,22 @@ public class IncrementalCacheVersionChangedTestGenerated extends AbstractIncreme
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("touchedOnlyJavaFile")
|
||||
public void testTouchedOnlyJavaFile() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/touchedOnlyJavaFile/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("untouchedFiles")
|
||||
public void testUntouchedFiles() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/untouchedFiles/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withError")
|
||||
public void testWithError() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/cacheVersionChanged/withError/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ import java.io.*
|
||||
import java.util.*
|
||||
import java.util.regex.Pattern
|
||||
import java.util.zip.ZipOutputStream
|
||||
import kotlin.test.*
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
companion object {
|
||||
@@ -234,7 +235,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
val buildResult = makeAll()
|
||||
buildResult.assertSuccessful()
|
||||
val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING)
|
||||
assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 2, warnings.size)
|
||||
assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 1, warnings.size)
|
||||
assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user