Do not wait for not generated classes in LowLevelDebuggerTestBase
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package org.jetbrains.kotlin.idea.debugger
|
||||
|
||||
import com.sun.jdi.ThreadReference
|
||||
import org.jetbrains.kotlin.codegen.ClassFileFactory
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.codegen.getClassFiles
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -12,9 +14,10 @@ abstract class AbstractFileRankingTest : LowLevelDebuggerTestBase() {
|
||||
options: Set<String>,
|
||||
mainThread: ThreadReference,
|
||||
factory: OriginCollectingClassBuilderFactory,
|
||||
classFileFactory: ClassFileFactory,
|
||||
state: GenerationState
|
||||
) {
|
||||
val allKtFiles = factory.origins.mapNotNull { it.value.element?.containingFile as? KtFile }.distinct()
|
||||
val allKtFiles = classFileFactory.inputFiles.distinct()
|
||||
fun getKtFiles(name: String) = allKtFiles.filter { it.name == name }
|
||||
|
||||
val doNotCheckClassFqName = "DO_NOT_CHECK_CLASS_FQNAME" in options
|
||||
@@ -26,16 +29,26 @@ abstract class AbstractFileRankingTest : LowLevelDebuggerTestBase() {
|
||||
|
||||
val problems = mutableListOf<String>()
|
||||
|
||||
val skipClasses = skipLoadingClasses(options)
|
||||
for ((node, origin) in factory.origins) {
|
||||
val classNode = node as? ClassNode ?: continue
|
||||
val expectedFile = origin.element?.containingFile as? KtFile ?: continue
|
||||
val className = classNode.name.replace('/', '.')
|
||||
val classNameToKtFile = factory.origins.asSequence()
|
||||
.filter { it.key is ClassNode }
|
||||
.map {
|
||||
val ktFile = (it.value.element?.containingFile as? KtFile) ?: return@map null
|
||||
val name = (it.key as ClassNode).name.replace('/', '.')
|
||||
|
||||
name to ktFile
|
||||
}
|
||||
.filterNotNull()
|
||||
.toMap()
|
||||
|
||||
val skipClasses = skipLoadingClasses(options)
|
||||
for (outputFile in classFileFactory.getClassFiles()) {
|
||||
val className = outputFile.internalName.replace('/', '.')
|
||||
if (className in skipClasses) {
|
||||
continue
|
||||
}
|
||||
|
||||
val expectedFile = classNameToKtFile[className] ?: throw IllegalStateException("Can't find source for $className")
|
||||
|
||||
val jdiClass = mainThread.virtualMachine().classesByName(className).singleOrNull()
|
||||
?: error("Class '$className' was not found in the debuggee process class loader")
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.backend.common.output.OutputFile
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.Socket
|
||||
@@ -63,8 +62,8 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() {
|
||||
|
||||
try {
|
||||
val mainThread = virtualMachine.allThreads().single { it.name() == "main" }
|
||||
waitUntil { areCompiledClassesLoaded(mainThread, classBuilderFactory, skipLoadingClasses) }
|
||||
doTest(options, mainThread, classBuilderFactory, generationState)
|
||||
waitUntil { areCompiledClassesLoaded(mainThread, classFileFactory, skipLoadingClasses) }
|
||||
doTest(options, mainThread, classBuilderFactory, classFileFactory, generationState)
|
||||
} finally {
|
||||
virtualMachine.exit(0)
|
||||
process.destroy()
|
||||
@@ -78,6 +77,7 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() {
|
||||
options: Set<String>,
|
||||
mainThread: ThreadReference,
|
||||
factory: OriginCollectingClassBuilderFactory,
|
||||
classFileFactory: ClassFileFactory,
|
||||
state: GenerationState
|
||||
)
|
||||
|
||||
@@ -92,13 +92,12 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() {
|
||||
|
||||
private fun areCompiledClassesLoaded(
|
||||
mainThread: ThreadReference,
|
||||
factory: OriginCollectingClassBuilderFactory,
|
||||
classFileFactory: ClassFileFactory,
|
||||
skipLoadingClasses: Set<String>
|
||||
): Boolean {
|
||||
for ((node, _) in factory.origins) {
|
||||
val classNode = node as? ClassNode ?: continue
|
||||
|
||||
val fqName = classNode.name.replace('/', '.')
|
||||
for (outputFile in classFileFactory.getClassFiles()) {
|
||||
val fqName = outputFile.internalName.replace('/', '.')
|
||||
if (fqName in skipLoadingClasses) {
|
||||
continue
|
||||
}
|
||||
@@ -155,10 +154,10 @@ abstract class LowLevelDebuggerTestBase : CodegenTestCase() {
|
||||
File(classesDir, mainClassResourceName).mkdirAndWriteBytes(mainClassBytes)
|
||||
}
|
||||
|
||||
private val OutputFile.internalName
|
||||
internal val OutputFile.internalName
|
||||
get() = relativePath.substringBeforeLast(".class")
|
||||
|
||||
private val OutputFile.qualifiedName
|
||||
internal val OutputFile.qualifiedName
|
||||
get() = internalName.replace('/', '.')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user