Show in lookup tracker log if there is no lookups in file
This commit is contained in:
+25
-16
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.jps.build
|
package org.jetbrains.kotlin.jps.build
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
|
||||||
import com.intellij.testFramework.UsefulTestCase
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
import com.intellij.util.containers.HashMap
|
import com.intellij.util.containers.HashMap
|
||||||
import com.intellij.util.containers.StringInterner
|
import com.intellij.util.containers.StringInterner
|
||||||
@@ -74,14 +73,25 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
|
|
||||||
fun doTest(path: String) {
|
fun doTest(path: String) {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
|
fun StringBuilder.indentln(string: String) {
|
||||||
|
appendln(" $string")
|
||||||
|
}
|
||||||
fun CompilerOutput.logOutput(stepName: String) {
|
fun CompilerOutput.logOutput(stepName: String) {
|
||||||
sb.appendln("==== $stepName ====")
|
sb.appendln("==== $stepName ====")
|
||||||
|
|
||||||
sb.appendln("Compiling files:")
|
sb.appendln("Compiling files:")
|
||||||
compiledFiles.map { it.toRelativeString(workingDir) }.sorted().forEach { sb.appendln(" " + it) }
|
for (compiledFile in compiledFiles.sortedBy { it.canonicalPath }) {
|
||||||
|
val lookupCount = lookupsCount[compiledFile]
|
||||||
|
val lookupStatus = when {
|
||||||
|
lookupCount == 0 -> "(no lookups)"
|
||||||
|
lookupCount != null && lookupCount > 0 -> ""
|
||||||
|
else -> "(unknown)"
|
||||||
|
}
|
||||||
|
sb.indentln("${compiledFile.toRelativeString(workingDir)}$lookupStatus")
|
||||||
|
}
|
||||||
|
|
||||||
sb.appendln("Exit code: $exitCode")
|
sb.appendln("Exit code: $exitCode")
|
||||||
errors.forEach { sb.appendln(" " + it) }
|
errors.forEach(sb::indentln)
|
||||||
|
|
||||||
sb.appendln()
|
sb.appendln()
|
||||||
}
|
}
|
||||||
@@ -106,7 +116,8 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
private class CompilerOutput(
|
private class CompilerOutput(
|
||||||
val exitCode: String,
|
val exitCode: String,
|
||||||
val errors: List<String>,
|
val errors: List<String>,
|
||||||
val compiledFiles: Iterable<File>
|
val compiledFiles: Iterable<File>,
|
||||||
|
val lookupsCount: Map<File, Int>
|
||||||
)
|
)
|
||||||
private class IncrementalData(val sourceToOutput: MutableMap<File, MutableSet<File>> = hashMapOf())
|
private class IncrementalData(val sourceToOutput: MutableMap<File, MutableSet<File>> = hashMapOf())
|
||||||
|
|
||||||
@@ -133,8 +144,6 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
val environment = createTestingCompilerEnvironment(messageCollector, outputItemsCollector, services)
|
val environment = createTestingCompilerEnvironment(messageCollector, outputItemsCollector, services)
|
||||||
val exitCode = runCompiler(filesToCompile, environment)
|
val exitCode = runCompiler(filesToCompile, environment)
|
||||||
|
|
||||||
checkLookups(filesToCompile, lookupTracker, workingToOriginalFileMap)
|
|
||||||
|
|
||||||
for (output in outputItemsCollector.outputs) {
|
for (output in outputItemsCollector.outputs) {
|
||||||
val outputFile = output.outputFile
|
val outputFile = output.outputFile
|
||||||
if (outputFile.extension == "kotlin_module") continue
|
if (outputFile.extension == "kotlin_module") continue
|
||||||
@@ -145,7 +154,8 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompilerOutput(exitCode.toString(), messageCollector.errors, filesToCompile)
|
val lookupsCount = checkLookups(filesToCompile, lookupTracker, workingToOriginalFileMap)
|
||||||
|
return CompilerOutput(exitCode.toString(), messageCollector.errors, filesToCompile, lookupsCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -182,13 +192,8 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
compiledFiles: Iterable<File>,
|
compiledFiles: Iterable<File>,
|
||||||
lookupTracker: TestLookupTracker,
|
lookupTracker: TestLookupTracker,
|
||||||
workingToOriginalFileMap: Map<File, File>
|
workingToOriginalFileMap: Map<File, File>
|
||||||
) {
|
): Map<File, Int> {
|
||||||
val fileToLookups = lookupTracker.lookups.groupBy { it.filePath }
|
fun checkLookupsInFile(expectedFile: File, actualFile: File, lookupsFromFile: List<LookupInfo>) {
|
||||||
|
|
||||||
fun checkLookupsInFile(expectedFile: File, actualFile: File) {
|
|
||||||
val independentFilePath = FileUtil.toSystemIndependentName(actualFile.path)
|
|
||||||
val lookupsFromFile = fileToLookups[independentFilePath] ?: error("No lookups from compiled file: $actualFile")
|
|
||||||
|
|
||||||
val text = actualFile.readText()
|
val text = actualFile.readText()
|
||||||
|
|
||||||
val matchResult = COMMENT_WITH_LOOKUP_INFO.find(text)
|
val matchResult = COMMENT_WITH_LOOKUP_INFO.find(text)
|
||||||
@@ -238,8 +243,12 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
|||||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (file in compiledFiles) {
|
val fileToLookups = lookupTracker.lookups.groupBy { File(it.filePath) }
|
||||||
checkLookupsInFile(workingToOriginalFileMap[file]!!, file)
|
return compiledFiles.associate { actualFile ->
|
||||||
|
val expectedFile = workingToOriginalFileMap[actualFile]!!
|
||||||
|
val lookupsInFile = fileToLookups[actualFile]
|
||||||
|
lookupsInFile?.let { checkLookupsInFile(expectedFile, actualFile, it) }
|
||||||
|
actualFile to (lookupsInFile?.size ?: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
==== INITIAL BUILD ====
|
==== INITIAL BUILD ====
|
||||||
Compiling files:
|
Compiling files:
|
||||||
src/bar.kt
|
src/bar.kt(no lookups)
|
||||||
src/locals.kt
|
src/locals.kt
|
||||||
Exit code: OK
|
Exit code: OK
|
||||||
Reference in New Issue
Block a user