IC: improve logging in tests and fix DataContainerVersionChangedTestGenerated#testWithError
Test logging improvements: * print which chunk building in the round for multimodule projects * print actions after cache changed
This commit is contained in:
@@ -16,20 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.jps.build
|
||||
|
||||
import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
import org.jetbrains.jps.incremental.ModuleLevelBuilder
|
||||
import org.jetbrains.kotlin.incremental.CacheVersion
|
||||
import java.io.File
|
||||
|
||||
interface BuildLogger {
|
||||
fun actionsOnCacheVersionChanged(actions: List<CacheVersion.Action>)
|
||||
fun buildStarted(context: CompileContext, chunk: ModuleChunk)
|
||||
fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode)
|
||||
fun markedAsDirty(files: Iterable<File>)
|
||||
|
||||
companion object {
|
||||
val DO_NOTHING = object : BuildLogger {
|
||||
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {
|
||||
}
|
||||
|
||||
override fun markedAsDirty(files: Iterable<File>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class FSOperationsHelper(
|
||||
internal var hasMarkedDirty = false
|
||||
private set
|
||||
|
||||
private val buildLogger = compileContext.testingContext?.buildLogger ?: BuildLogger.DO_NOTHING
|
||||
private val buildLogger = compileContext.testingContext?.buildLogger
|
||||
|
||||
fun markChunk(recursively: Boolean, kotlinOnly: Boolean, excludeFiles: Set<File> = setOf()) {
|
||||
fun shouldMark(file: File): Boolean {
|
||||
@@ -56,7 +56,7 @@ class FSOperationsHelper(
|
||||
filesToMark.removeAll(excludeFiles)
|
||||
|
||||
log.debug("Mark dirty: $filesToMark")
|
||||
buildLogger.markedAsDirty(filesToMark)
|
||||
buildLogger?.markedAsDirty(filesToMark)
|
||||
|
||||
for (file in filesToMark) {
|
||||
if (!file.exists()) continue
|
||||
|
||||
@@ -103,6 +103,8 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
override fun chunkBuildStarted(context: CompileContext, chunk: ModuleChunk) {
|
||||
super.chunkBuildStarted(context, chunk)
|
||||
|
||||
context.testingContext?.buildLogger?.buildStarted(context, chunk)
|
||||
|
||||
if (JavaBuilderUtil.isForcedRecompilationAllJavaModules(context)) return
|
||||
|
||||
val targets = chunk.targets
|
||||
@@ -142,9 +144,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
|
||||
LOG.info("Build result: " + actualExitCode)
|
||||
|
||||
context.testingContext?.run {
|
||||
buildLogger.buildFinished(actualExitCode)
|
||||
}
|
||||
context.testingContext?.buildLogger?.buildFinished(actualExitCode)
|
||||
|
||||
return actualExitCode
|
||||
}
|
||||
@@ -294,7 +294,11 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
val hasKotlin = HasKotlinMarker(dataManager)
|
||||
val rebuildAfterCacheVersionChanged = RebuildAfterCacheVersionChangeMarker(dataManager)
|
||||
|
||||
for (status in actions.sorted()) {
|
||||
val sortedActions = actions.sorted()
|
||||
|
||||
context.testingContext?.buildLogger?.actionsOnCacheVersionChanged(sortedActions)
|
||||
|
||||
for (status in sortedActions) {
|
||||
when (status) {
|
||||
CacheVersion.Action.REBUILD_ALL_KOTLIN -> {
|
||||
LOG.info("Kotlin global lookup map format changed, so rebuild all kotlin")
|
||||
@@ -879,8 +883,3 @@ private fun hasKotlinDirtyOrRemovedFiles(
|
||||
return chunk.targets.any { KotlinSourceFileCollector.getRemovedKotlinFiles(dirtyFilesHolder, it).isNotEmpty() }
|
||||
}
|
||||
|
||||
private inline fun Logger.debug(message: ()->String) {
|
||||
if (isDebugEnabled) {
|
||||
debug(message())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user