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
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import com.intellij.util.containers.HashMap
|
||||
import com.intellij.util.containers.StringInterner
|
||||
@@ -74,14 +73,25 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
||||
|
||||
fun doTest(path: String) {
|
||||
val sb = StringBuilder()
|
||||
fun StringBuilder.indentln(string: String) {
|
||||
appendln(" $string")
|
||||
}
|
||||
fun CompilerOutput.logOutput(stepName: String) {
|
||||
sb.appendln("==== $stepName ====")
|
||||
|
||||
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")
|
||||
errors.forEach { sb.appendln(" " + it) }
|
||||
errors.forEach(sb::indentln)
|
||||
|
||||
sb.appendln()
|
||||
}
|
||||
@@ -106,7 +116,8 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
||||
private class CompilerOutput(
|
||||
val exitCode: 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())
|
||||
|
||||
@@ -133,8 +144,6 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
||||
val environment = createTestingCompilerEnvironment(messageCollector, outputItemsCollector, services)
|
||||
val exitCode = runCompiler(filesToCompile, environment)
|
||||
|
||||
checkLookups(filesToCompile, lookupTracker, workingToOriginalFileMap)
|
||||
|
||||
for (output in outputItemsCollector.outputs) {
|
||||
val outputFile = output.outputFile
|
||||
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>,
|
||||
lookupTracker: TestLookupTracker,
|
||||
workingToOriginalFileMap: Map<File, File>
|
||||
) {
|
||||
val fileToLookups = lookupTracker.lookups.groupBy { it.filePath }
|
||||
|
||||
fun checkLookupsInFile(expectedFile: File, actualFile: File) {
|
||||
val independentFilePath = FileUtil.toSystemIndependentName(actualFile.path)
|
||||
val lookupsFromFile = fileToLookups[independentFilePath] ?: error("No lookups from compiled file: $actualFile")
|
||||
|
||||
): Map<File, Int> {
|
||||
fun checkLookupsInFile(expectedFile: File, actualFile: File, lookupsFromFile: List<LookupInfo>) {
|
||||
val text = actualFile.readText()
|
||||
|
||||
val matchResult = COMMENT_WITH_LOOKUP_INFO.find(text)
|
||||
@@ -238,8 +243,12 @@ abstract class AbstractLookupTrackerTest : TestWithWorkingDir() {
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||
}
|
||||
|
||||
for (file in compiledFiles) {
|
||||
checkLookupsInFile(workingToOriginalFileMap[file]!!, file)
|
||||
val fileToLookups = lookupTracker.lookups.groupBy { File(it.filePath) }
|
||||
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 ====
|
||||
Compiling files:
|
||||
src/bar.kt
|
||||
src/bar.kt(no lookups)
|
||||
src/locals.kt
|
||||
Exit code: OK
|
||||
Reference in New Issue
Block a user