+80
-160
@@ -40,26 +40,21 @@ import org.jetbrains.jps.cmdline.ProjectDescriptor
|
|||||||
import org.jetbrains.jps.incremental.*
|
import org.jetbrains.jps.incremental.*
|
||||||
import org.jetbrains.jps.incremental.messages.BuildMessage
|
import org.jetbrains.jps.incremental.messages.BuildMessage
|
||||||
import org.jetbrains.jps.model.JpsModuleRootModificationUtil
|
import org.jetbrains.jps.model.JpsModuleRootModificationUtil
|
||||||
|
import org.jetbrains.jps.model.java.JpsJavaDependencyScope
|
||||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
import org.jetbrains.jps.model.java.JpsJavaExtensionService
|
||||||
import org.jetbrains.jps.util.JpsPathUtil
|
import org.jetbrains.jps.util.JpsPathUtil
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||||
import org.jetbrains.kotlin.incremental.isJavaFile
|
import org.jetbrains.kotlin.incremental.isJavaFile
|
||||||
import org.jetbrains.kotlin.incremental.testingUtils.*
|
import org.jetbrains.kotlin.incremental.testingUtils.*
|
||||||
import org.jetbrains.kotlin.jps.build.dependeciestxt.DependenciesTxt
|
|
||||||
import org.jetbrains.kotlin.jps.build.dependeciestxt.DependenciesTxtBuilder
|
|
||||||
import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
||||||
import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
||||||
import org.jetbrains.kotlin.jps.model.JpsKotlinFacetModuleExtension
|
|
||||||
import org.jetbrains.kotlin.jps.platforms.kotlinBuildTargets
|
import org.jetbrains.kotlin.jps.platforms.kotlinBuildTargets
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import java.io.ByteArrayInputStream
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.*
|
||||||
import java.io.File
|
|
||||||
import java.io.PrintStream
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
import kotlin.reflect.jvm.javaField
|
import kotlin.reflect.jvm.javaField
|
||||||
@@ -84,7 +79,6 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
// is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage)
|
// is used to compare lookup dumps in a human readable way (lookup symbols are hashed in an actual lookup storage)
|
||||||
protected lateinit var lookupsDuringTest: MutableSet<LookupSymbol>
|
protected lateinit var lookupsDuringTest: MutableSet<LookupSymbol>
|
||||||
private var isICEnabledBackup: Boolean = false
|
private var isICEnabledBackup: Boolean = false
|
||||||
private var isJSICEnabledBackup: Boolean = false
|
|
||||||
|
|
||||||
protected var mapWorkingToOriginalFile: MutableMap<File, File> = hashMapOf()
|
protected var mapWorkingToOriginalFile: MutableMap<File, File> = hashMapOf()
|
||||||
|
|
||||||
@@ -121,10 +115,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
super.setUp()
|
super.setUp()
|
||||||
lookupsDuringTest = hashSetOf()
|
lookupsDuringTest = hashSetOf()
|
||||||
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
isICEnabledBackup = IncrementalCompilation.isEnabled()
|
||||||
isJSICEnabledBackup = IncrementalCompilation.isEnabledForJs()
|
|
||||||
|
|
||||||
IncrementalCompilation.setIsEnabled(true)
|
IncrementalCompilation.setIsEnabled(true)
|
||||||
IncrementalCompilation.setIsEnabledForJs(true)
|
|
||||||
|
|
||||||
if (DEBUG_LOGGING_ENABLED) {
|
if (DEBUG_LOGGING_ENABLED) {
|
||||||
enableDebugLogging()
|
enableDebugLogging()
|
||||||
@@ -138,7 +129,6 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
(AbstractIncrementalJpsTest::systemPropertiesBackup).javaField!![this] = null
|
(AbstractIncrementalJpsTest::systemPropertiesBackup).javaField!![this] = null
|
||||||
lookupsDuringTest.clear()
|
lookupsDuringTest.clear()
|
||||||
IncrementalCompilation.setIsEnabled(isICEnabledBackup)
|
IncrementalCompilation.setIsEnabled(isICEnabledBackup)
|
||||||
IncrementalCompilation.setIsEnabledForJs(isJSICEnabledBackup)
|
|
||||||
super.tearDown()
|
super.tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +138,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
private val mockConstantSearch: Callbacks.ConstantAffectionResolver?
|
private val mockConstantSearch: Callbacks.ConstantAffectionResolver?
|
||||||
get() = MockJavaConstantSearch(workDir)
|
get() = MockJavaConstantSearch(workDir)
|
||||||
|
|
||||||
private fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules(), name: String? = null): MakeResult {
|
private fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules()): MakeResult {
|
||||||
val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
|
val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
|
||||||
|
|
||||||
val logger = MyLogger(workDirPath)
|
val logger = MyLogger(workDirPath)
|
||||||
@@ -158,17 +148,9 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
projectDescriptor.project.setTestingContext(TestingContext(lookupTracker, logger))
|
projectDescriptor.project.setTestingContext(TestingContext(lookupTracker, logger))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val builder = IncProjectBuilder(
|
val builder = IncProjectBuilder(projectDescriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, mockConstantSearch, true)
|
||||||
projectDescriptor,
|
|
||||||
BuilderRegistry.getInstance(),
|
|
||||||
myBuildParams,
|
|
||||||
CanceledStatus.NULL,
|
|
||||||
mockConstantSearch,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
val buildResult = BuildResult()
|
val buildResult = BuildResult()
|
||||||
builder.addMessageHandler(buildResult)
|
builder.addMessageHandler(buildResult)
|
||||||
|
|
||||||
val finalScope = scope.build()
|
val finalScope = scope.build()
|
||||||
builder.build(finalScope, false)
|
builder.build(finalScope, false)
|
||||||
|
|
||||||
@@ -184,41 +166,34 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
.map { it.messageText }
|
.map { it.messageText }
|
||||||
.map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() }
|
.map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() }
|
||||||
.joinToString("\n")
|
.joinToString("\n")
|
||||||
return MakeResult(
|
return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null)
|
||||||
logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n",
|
|
||||||
true,
|
|
||||||
null,
|
|
||||||
name
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return MakeResult(
|
|
||||||
logger.log,
|
|
||||||
false,
|
|
||||||
createMappingsDump(projectDescriptor, dummyCompileContext),
|
|
||||||
name
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} finally {
|
else {
|
||||||
|
return MakeResult(logger.log, false, createMappingsDump(projectDescriptor, dummyCompileContext))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
projectDescriptor.dataManager.flush(false)
|
projectDescriptor.dataManager.flush(false)
|
||||||
projectDescriptor.release()
|
projectDescriptor.release()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun initialMake(): MakeResult {
|
private fun initialMake(): MakeResult {
|
||||||
val makeResult = build(name = "initial")
|
val makeResult = build()
|
||||||
|
|
||||||
val initBuildLogFile = File(testDataDir, "init-build.log")
|
val initBuildLogFile = File(testDataDir, "init-build.log")
|
||||||
if (initBuildLogFile.exists()) {
|
if (initBuildLogFile.exists()) {
|
||||||
UsefulTestCase.assertSameLinesWithFile(initBuildLogFile.absolutePath, makeResult.log)
|
UsefulTestCase.assertSameLinesWithFile(initBuildLogFile.absolutePath, makeResult.log)
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
assertFalse("Initial make failed:\n$makeResult", makeResult.makeFailed)
|
assertFalse("Initial make failed:\n$makeResult", makeResult.makeFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeResult
|
return makeResult
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun make(name: String?): MakeResult {
|
private fun make(): MakeResult {
|
||||||
return build(name = name)
|
return build()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rebuild(): MakeResult {
|
private fun rebuild(): MakeResult {
|
||||||
@@ -234,21 +209,21 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val rebuildResult = rebuild()
|
val rebuildResult = rebuild()
|
||||||
assertEquals(
|
assertEquals("Rebuild failed: ${rebuildResult.makeFailed}, last make failed: ${makeOverallResult.makeFailed}. Rebuild result: $rebuildResult",
|
||||||
"Rebuild failed: ${rebuildResult.makeFailed}, last make failed: ${makeOverallResult.makeFailed}. Rebuild result: $rebuildResult",
|
rebuildResult.makeFailed, makeOverallResult.makeFailed)
|
||||||
rebuildResult.makeFailed, makeOverallResult.makeFailed
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!outAfterMake.exists()) {
|
if (!outAfterMake.exists()) {
|
||||||
assertFalse(outDir.exists())
|
assertFalse(outDir.exists())
|
||||||
} else {
|
}
|
||||||
assertEqualDirectories(outAfterMake, outDir, makeOverallResult.makeFailed)
|
else {
|
||||||
|
assertEqualDirectories(outDir, outAfterMake, makeOverallResult.makeFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!makeOverallResult.makeFailed) {
|
if (!makeOverallResult.makeFailed) {
|
||||||
if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) {
|
if (checkDumpsCaseInsensitively && rebuildResult.mappingsDump?.toLowerCase() == makeOverallResult.mappingsDump?.toLowerCase()) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump)
|
TestCase.assertEquals(rebuildResult.mappingsDump, makeOverallResult.mappingsDump)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,24 +237,27 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
rebuildAndCheckOutput(makeOverallResult)
|
rebuildAndCheckOutput(makeOverallResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
open protected val dependenciesTxtFile get() = File(testDataDir, "dependencies.txt")
|
private fun readModuleDependencies(): Map<String, List<DependencyDescriptor>>? {
|
||||||
|
val dependenciesTxt = File(testDataDir, "dependencies.txt")
|
||||||
|
if (!dependenciesTxt.exists()) return null
|
||||||
|
|
||||||
private fun readModuleDependencies(): DependenciesTxt? {
|
val result = HashMap<String, List<DependencyDescriptor>>()
|
||||||
val dependenciesTxtFile = dependenciesTxtFile
|
for (line in dependenciesTxt.readLines()) {
|
||||||
if (!dependenciesTxtFile.exists()) return null
|
val split = line.split("->")
|
||||||
|
val module = split[0]
|
||||||
|
val dependencies = if (split.size > 1) split[1] else ""
|
||||||
|
val dependencyList = dependencies.split(",").filterNot { it.isEmpty() }
|
||||||
|
result[module] = dependencyList.map(::parseDependency)
|
||||||
|
}
|
||||||
|
|
||||||
return DependenciesTxtBuilder().readFile(dependenciesTxtFile)
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun createBuildLog(incrementalMakeResults: List<AbstractIncrementalJpsTest.MakeResult>): String =
|
protected open fun createBuildLog(incrementalMakeResults: List<AbstractIncrementalJpsTest.MakeResult>): String =
|
||||||
buildString {
|
buildString {
|
||||||
incrementalMakeResults.forEachIndexed { i, makeResult ->
|
incrementalMakeResults.forEachIndexed { i, makeResult ->
|
||||||
if (i > 0) append("\n")
|
if (i > 0) append("\n")
|
||||||
if (makeResult.name != null) {
|
append("================ Step #${i + 1} =================\n\n")
|
||||||
append("================ Step #${i + 1} ${makeResult.name} =================\n\n")
|
|
||||||
} else {
|
|
||||||
append("================ Step #${i + 1} =================\n\n")
|
|
||||||
}
|
|
||||||
append(makeResult.log)
|
append(makeResult.log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,7 +276,8 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
|
|
||||||
if (buildLogFile != null && buildLogFile.exists()) {
|
if (buildLogFile != null && buildLogFile.exists()) {
|
||||||
UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs)
|
UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, logs)
|
||||||
} else if (!allowNoBuildLogFileInTestData) {
|
}
|
||||||
|
else if (!allowNoBuildLogFileInTestData) {
|
||||||
throw IllegalStateException("No build log file in $testDataDir")
|
throw IllegalStateException("No build log file in $testDataDir")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,26 +286,10 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun doInitialMakeTest(testDataPath: String) {
|
|
||||||
testDataDir = File(testDataPath)
|
|
||||||
workDir = FileUtilRt.createTempDirectory(TEMP_DIRECTORY_TO_USE, "jps-build", null)
|
|
||||||
Disposer.register(testRootDisposable, Disposable { FileUtilRt.delete(workDir) })
|
|
||||||
|
|
||||||
configureModules()
|
|
||||||
val results = initialMake()
|
|
||||||
|
|
||||||
val buildLogFile = buildLogFinder.findBuildLog(testDataDir)
|
|
||||||
|
|
||||||
if (buildLogFile != null && buildLogFile.exists()) {
|
|
||||||
UsefulTestCase.assertSameLinesWithFile(buildLogFile.absolutePath, results.log)
|
|
||||||
} else throw IllegalStateException("No build log file in $testDataDir")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createMappingsDump(
|
private fun createMappingsDump(
|
||||||
project: ProjectDescriptor,
|
project: ProjectDescriptor,
|
||||||
dummyCompileContext: CompileContext
|
dummyCompileContext: CompileContext
|
||||||
) =
|
) = createKotlinIncrementalCacheDump(project, dummyCompileContext) + "\n\n\n" +
|
||||||
createKotlinIncrementalCacheDump(project, dummyCompileContext) + "\n\n\n" +
|
|
||||||
createLookupCacheDump(project) + "\n\n\n" +
|
createLookupCacheDump(project) + "\n\n\n" +
|
||||||
createCommonMappingsDump(project) + "\n\n\n" +
|
createCommonMappingsDump(project) + "\n\n\n" +
|
||||||
createJavaMappingsDump(project)
|
createJavaMappingsDump(project)
|
||||||
@@ -396,35 +359,23 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
return byteArrayOutputStream.toString()
|
return byteArrayOutputStream.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected data class MakeResult(
|
protected data class MakeResult(val log: String, val makeFailed: Boolean, val mappingsDump: String?)
|
||||||
val log: String,
|
|
||||||
val makeFailed: Boolean,
|
|
||||||
val mappingsDump: String?,
|
|
||||||
val name: String?
|
|
||||||
)
|
|
||||||
|
|
||||||
open val testDataSrc: File
|
|
||||||
get() = testDataDir
|
|
||||||
|
|
||||||
private fun performModificationsAndMake(moduleNames: Set<String>?): List<MakeResult> {
|
private fun performModificationsAndMake(moduleNames: Set<String>?): List<MakeResult> {
|
||||||
val results = arrayListOf<MakeResult>()
|
val results = arrayListOf<MakeResult>()
|
||||||
val modifications = getModificationsToPerform(testDataSrc, moduleNames, allowNoFilesWithSuffixInTestData, TouchPolicy.TIMESTAMP)
|
val modifications = getModificationsToPerform(testDataDir, moduleNames, allowNoFilesWithSuffixInTestData, TouchPolicy.TIMESTAMP)
|
||||||
|
|
||||||
val stepsTxt = File(testDataSrc, "steps.txt")
|
for (step in modifications) {
|
||||||
val modificationNames = if (stepsTxt.exists()) stepsTxt.readLines() else null
|
|
||||||
|
|
||||||
modifications.forEachIndexed { index, step ->
|
|
||||||
step.forEach { it.perform(workDir, mapWorkingToOriginalFile) }
|
step.forEach { it.perform(workDir, mapWorkingToOriginalFile) }
|
||||||
performAdditionalModifications(step)
|
performAdditionalModifications(step)
|
||||||
if (moduleNames == null) {
|
if (moduleNames == null) {
|
||||||
preProcessSources(File(workDir, "src"))
|
preProcessSources(File(workDir, "src"))
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
moduleNames.forEach { preProcessSources(File(workDir, "$it/src")) }
|
moduleNames.forEach { preProcessSources(File(workDir, "$it/src")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
val name = modificationNames?.getOrNull(index)
|
results.add(make())
|
||||||
val makeResult = make(name)
|
|
||||||
results.add(makeResult)
|
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
@@ -432,92 +383,54 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
protected open fun performAdditionalModifications(modifications: List<Modification>) {
|
protected open fun performAdditionalModifications(modifications: List<Modification>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun generateModuleSources(dependenciesTxt: DependenciesTxt) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected open fun prepareModuleSources(module: DependenciesTxt.Module? = null) {
|
|
||||||
if (module != null) {
|
|
||||||
prepareModuleSourcesByName("${module.name}/src", "${module.name}_")
|
|
||||||
} else {
|
|
||||||
prepareModuleSourcesByName("src", "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun prepareIndexedModuleSources(module: DependenciesTxt.Module) {
|
|
||||||
prepareModuleSourcesByName("${module.name}/src", "${module.indexedName}_")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun prepareModuleSourcesByName(sourceDirName: String, filePrefix: String) {
|
|
||||||
val sourceDestinationDir = File(workDir, sourceDirName)
|
|
||||||
val sourcesMapping = copyTestSources(testDataSrc, sourceDestinationDir, filePrefix)
|
|
||||||
mapWorkingToOriginalFile.putAll(sourcesMapping)
|
|
||||||
preProcessSources(sourceDestinationDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
// null means one module
|
// null means one module
|
||||||
protected fun configureModules(): Set<String>? {
|
private fun configureModules(): Set<String>? {
|
||||||
val outputUrl = JpsPathUtil.pathToUrl(getAbsolutePath("out"))
|
fun prepareModuleSources(moduleName: String?) {
|
||||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = outputUrl
|
val sourceDirName = moduleName?.let { "$it/src" } ?: "src"
|
||||||
|
val filePrefix = moduleName?.let { "${it}_" } ?: ""
|
||||||
|
val sourceDestinationDir = File(workDir, sourceDirName)
|
||||||
|
val sourcesMapping = copyTestSources(testDataDir, sourceDestinationDir, filePrefix)
|
||||||
|
mapWorkingToOriginalFile.putAll(sourcesMapping)
|
||||||
|
preProcessSources(sourceDestinationDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = JpsPathUtil.pathToUrl(getAbsolutePath("out"))
|
||||||
|
|
||||||
val jdk = addJdk("my jdk")
|
val jdk = addJdk("my jdk")
|
||||||
val dependenciesTxt = readModuleDependencies()
|
val moduleDependencies = readModuleDependencies()
|
||||||
mapWorkingToOriginalFile = hashMapOf()
|
mapWorkingToOriginalFile = hashMapOf()
|
||||||
|
|
||||||
val moduleNames: Set<String>?
|
val moduleNames: Set<String>?
|
||||||
if (dependenciesTxt == null) {
|
if (moduleDependencies == null) {
|
||||||
addModule("module", arrayOf(getAbsolutePath("src")), null, null, jdk)
|
addModule("module", arrayOf(getAbsolutePath("src")), null, null, jdk)
|
||||||
prepareModuleSources(module = null)
|
prepareModuleSources(moduleName = null)
|
||||||
moduleNames = null
|
moduleNames = null
|
||||||
} else {
|
}
|
||||||
dependenciesTxt.modules.forEach {
|
else {
|
||||||
val module = addModule(
|
val nameToModule = moduleDependencies.keys
|
||||||
it.name,
|
.keysToMap { addModule(it, arrayOf(getAbsolutePath("$it/src")), null, null, jdk)!! }
|
||||||
arrayOf(getAbsolutePath("${it.name}/src")),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
jdk
|
|
||||||
)!!
|
|
||||||
|
|
||||||
val kotlinFacetSettings = it.kotlinFacetSettings
|
for ((moduleName, dependencies) in moduleDependencies) {
|
||||||
if (kotlinFacetSettings != null) {
|
val module = nameToModule[moduleName]!!
|
||||||
val compilerArguments = kotlinFacetSettings.compilerArguments
|
|
||||||
if (compilerArguments is K2MetadataCompilerArguments) {
|
|
||||||
val out = getAbsolutePath("${it.name}/out")
|
|
||||||
File(out).mkdirs()
|
|
||||||
compilerArguments.destination = out
|
|
||||||
}
|
|
||||||
|
|
||||||
module.container.setChild(
|
for (dependency in dependencies) {
|
||||||
JpsKotlinFacetModuleExtension.KIND,
|
JpsModuleRootModificationUtil.addDependency(module, nameToModule[dependency.name],
|
||||||
JpsKotlinFacetModuleExtension(kotlinFacetSettings)
|
JpsJavaDependencyScope.COMPILE, dependency.exported)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it.jpsModule = module
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependenciesTxt.dependencies.forEach {
|
for (module in nameToModule.values) {
|
||||||
JpsModuleRootModificationUtil.addDependency(
|
prepareModuleSources(module.name)
|
||||||
it.from.jpsModule,
|
|
||||||
it.to.jpsModule,
|
|
||||||
it.scope,
|
|
||||||
it.exported
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generateModuleSources(dependenciesTxt)
|
moduleNames = nameToModule.keys
|
||||||
dependenciesTxt.modules.forEach {
|
|
||||||
prepareModuleSources(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleNames = dependenciesTxt.modules.map { it.name }.toSet()
|
|
||||||
}
|
}
|
||||||
AbstractKotlinJpsBuildTestCase.addKotlinStdlibDependency(myProject)
|
AbstractKotlinJpsBuildTestCase.addKotlinStdlibDependency(myProject)
|
||||||
AbstractKotlinJpsBuildTestCase.addKotlinTestDependency(myProject)
|
AbstractKotlinJpsBuildTestCase.addKotlinTestDependency(myProject)
|
||||||
return moduleNames
|
return moduleNames
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun preProcessSources(srcDir: File) {
|
protected open fun preProcessSources(srcDir: File) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,3 +539,10 @@ private class MockJavaConstantSearch(private val workDir: File) : Callbacks.Cons
|
|||||||
|
|
||||||
internal val ProjectDescriptor.allModuleTargets: Collection<ModuleBuildTarget>
|
internal val ProjectDescriptor.allModuleTargets: Collection<ModuleBuildTarget>
|
||||||
get() = buildTargetIndex.allTargets.filterIsInstance<ModuleBuildTarget>()
|
get() = buildTargetIndex.allTargets.filterIsInstance<ModuleBuildTarget>()
|
||||||
|
|
||||||
|
private class DependencyDescriptor(val name: String, val exported: Boolean)
|
||||||
|
|
||||||
|
private fun parseDependency(dependency: String): DependencyDescriptor =
|
||||||
|
DependencyDescriptor(dependency.removeSuffix(EXPORTED_SUFFIX), dependency.endsWith(EXPORTED_SUFFIX))
|
||||||
|
|
||||||
|
private val EXPORTED_SUFFIX = "[exported]"
|
||||||
|
|||||||
+17
-6
@@ -46,9 +46,11 @@ import org.jetbrains.jps.util.JpsPathUtil
|
|||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||||
|
import org.jetbrains.kotlin.incremental.isJavaFile
|
||||||
import org.jetbrains.kotlin.incremental.testingUtils.*
|
import org.jetbrains.kotlin.incremental.testingUtils.*
|
||||||
import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
import org.jetbrains.kotlin.jps.incremental.getKotlinCache
|
||||||
import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
import org.jetbrains.kotlin.jps.incremental.withLookupStorage
|
||||||
|
import org.jetbrains.kotlin.jps.platforms.kotlinBuildTargets
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.utils.Printer
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import org.jetbrains.kotlin.utils.keysToMap
|
import org.jetbrains.kotlin.utils.keysToMap
|
||||||
@@ -148,10 +150,14 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
val builder = IncProjectBuilder(projectDescriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, mockConstantSearch, true)
|
val builder = IncProjectBuilder(projectDescriptor, BuilderRegistry.getInstance(), myBuildParams, CanceledStatus.NULL, mockConstantSearch, true)
|
||||||
val buildResult = BuildResult()
|
val buildResult = BuildResult()
|
||||||
builder.addMessageHandler(buildResult)
|
builder.addMessageHandler(buildResult)
|
||||||
builder.build(scope.build(), false)
|
val finalScope = scope.build()
|
||||||
|
builder.build(finalScope, false)
|
||||||
|
|
||||||
lookupTracker.lookups.mapTo(lookupsDuringTest) { LookupSymbol(it.name, it.scopeFqName) }
|
lookupTracker.lookups.mapTo(lookupsDuringTest) { LookupSymbol(it.name, it.scopeFqName) }
|
||||||
|
|
||||||
|
// for getting kotlin platform only
|
||||||
|
val dummyCompileContext = CompileContextImpl.createContextForTests(finalScope, projectDescriptor)
|
||||||
|
|
||||||
if (!buildResult.isSuccessful) {
|
if (!buildResult.isSuccessful) {
|
||||||
val errorMessages =
|
val errorMessages =
|
||||||
buildResult
|
buildResult
|
||||||
@@ -162,7 +168,7 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null)
|
return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return MakeResult(logger.log, false, createMappingsDump(projectDescriptor))
|
return MakeResult(logger.log, false, createMappingsDump(projectDescriptor, dummyCompileContext))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -279,17 +285,22 @@ abstract class AbstractIncrementalJpsTest(
|
|||||||
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
clearCachesRebuildAndCheckOutput(lastMakeResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMappingsDump(project: ProjectDescriptor) =
|
private fun createMappingsDump(
|
||||||
createKotlinIncrementalCacheDump(project) + "\n\n\n" +
|
project: ProjectDescriptor,
|
||||||
|
dummyCompileContext: CompileContext
|
||||||
|
) = createKotlinIncrementalCacheDump(project, dummyCompileContext) + "\n\n\n" +
|
||||||
createLookupCacheDump(project) + "\n\n\n" +
|
createLookupCacheDump(project) + "\n\n\n" +
|
||||||
createCommonMappingsDump(project) + "\n\n\n" +
|
createCommonMappingsDump(project) + "\n\n\n" +
|
||||||
createJavaMappingsDump(project)
|
createJavaMappingsDump(project)
|
||||||
|
|
||||||
private fun createKotlinIncrementalCacheDump(project: ProjectDescriptor): String {
|
private fun createKotlinIncrementalCacheDump(
|
||||||
|
project: ProjectDescriptor,
|
||||||
|
dummyCompileContext: CompileContext
|
||||||
|
): String {
|
||||||
return buildString {
|
return buildString {
|
||||||
for (target in project.allModuleTargets.sortedBy { it.presentableName }) {
|
for (target in project.allModuleTargets.sortedBy { it.presentableName }) {
|
||||||
append("<target $target>\n")
|
append("<target $target>\n")
|
||||||
append(project.dataManager.getKotlinCache(target).dump())
|
append(project.dataManager.getKotlinCache(dummyCompileContext.kotlinBuildTargets[target]!!).dump())
|
||||||
append("</target $target>\n\n\n")
|
append("</target $target>\n\n\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-23
@@ -10,28 +10,7 @@ import org.jetbrains.kotlin.jps.build.dependeciestxt.MppJpsIncTestsGenerator
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class AbstractMultiplatformJpsTest : AbstractIncrementalJpsTest() {
|
abstract class AbstractMultiplatformJpsTest : AbstractIncrementalJpsTest() {
|
||||||
override val dependenciesTxtFile: File
|
override fun doTest(testDataPath: String) {
|
||||||
get() = File(testDataDir.parent, "dependencies.txt").also {
|
// temporary ignore jps-plugin/testData/incremental/multiplatform/multiModule tests
|
||||||
check(it.exists()) {
|
|
||||||
"`dependencies.txt` should be in parent dir. " +
|
|
||||||
"See jps-plugin/testData/incremental/multiplatform/multiModule/README.md for details"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val testDataSrc: File
|
|
||||||
get() = File(workDir, "generatedTestDataSources")
|
|
||||||
|
|
||||||
override fun generateModuleSources(dependenciesTxt: DependenciesTxt) {
|
|
||||||
testDataSrc.mkdirs()
|
|
||||||
|
|
||||||
val testCaseName = testDataDir.name
|
|
||||||
|
|
||||||
val generator = MppJpsIncTestsGenerator(dependenciesTxt) { testDataSrc }
|
|
||||||
val testCase = generator.testCases.find { it.name == testCaseName } ?: error("Unsupported test case name: $testCaseName")
|
|
||||||
testCase.generate()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun prepareModuleSources(module: DependenciesTxt.Module?) {
|
|
||||||
prepareIndexedModuleSources(module!!)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,10 +231,6 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
|||||||
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>,
|
dirtyFilesHolder: DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>,
|
||||||
outputConsumer: ModuleLevelBuilder.OutputConsumer
|
outputConsumer: ModuleLevelBuilder.OutputConsumer
|
||||||
): ModuleLevelBuilder.ExitCode {
|
): ModuleLevelBuilder.ExitCode {
|
||||||
JavaBuilderUtil.registerFilterToSkipMarkingAffectedFileDirty(context) {
|
|
||||||
it.isKotlinSourceFile
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chunk.isDummy(context))
|
if (chunk.isDummy(context))
|
||||||
return NOTHING_DONE
|
return NOTHING_DONE
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ Exit code: ADDITIONAL_PASS_REQUIRED
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
Exit code: NOTHING_DONE
|
Exit code: NOTHING_DONE
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
Building module2
|
||||||
|
Cleaning output files:
|
||||||
|
out/production/module2/META-INF/module2.kotlin_module
|
||||||
|
out/production/module2/b/BKt.class
|
||||||
|
End of files
|
||||||
|
Compiling files:
|
||||||
|
module2/src/b.kt
|
||||||
|
End of files
|
||||||
|
Exit code: OK
|
||||||
|
------------------------------------------
|
||||||
Building module3
|
Building module3
|
||||||
Cleaning output files:
|
Cleaning output files:
|
||||||
out/production/module3/META-INF/module3.kotlin_module
|
out/production/module3/META-INF/module3.kotlin_module
|
||||||
@@ -26,13 +36,3 @@ Compiling files:
|
|||||||
End of files
|
End of files
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
Building module2
|
|
||||||
Cleaning output files:
|
|
||||||
out/production/module2/META-INF/module2.kotlin_module
|
|
||||||
out/production/module2/b/BKt.class
|
|
||||||
End of files
|
|
||||||
Compiling files:
|
|
||||||
module2/src/b.kt
|
|
||||||
End of files
|
|
||||||
Exit code: OK
|
|
||||||
------------------------------------------
|
|
||||||
Reference in New Issue
Block a user