Drop state from debugger tests
This commit is contained in:
@@ -50,13 +50,15 @@ import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
|||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes
|
||||||
import javax.swing.SwingUtilities
|
import javax.swing.SwingUtilities
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
||||||
private var oldSettings: DebuggerSettings by Delegates.notNull()
|
private var oldSettings: DebuggerSettings? = null
|
||||||
private var oldIsFilterForStdlibAlreadyAdded: Boolean by Delegates.notNull()
|
private var oldIsFilterForStdlibAlreadyAdded = false
|
||||||
private var oldDisableKotlinInternalClasses: Boolean by Delegates.notNull()
|
private var oldDisableKotlinInternalClasses = false
|
||||||
private var oldRenderDelegatedProperties: Boolean by Delegates.notNull()
|
private var oldRenderDelegatedProperties = false
|
||||||
|
|
||||||
|
protected var evaluationContext: EvaluationContextImpl? = null
|
||||||
|
protected var debuggerContext: DebuggerContextImpl? = null
|
||||||
|
|
||||||
override fun initApplication() {
|
override fun initApplication() {
|
||||||
super.initApplication()
|
super.initApplication()
|
||||||
@@ -66,6 +68,9 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
|||||||
override fun tearDown() {
|
override fun tearDown() {
|
||||||
super.tearDown()
|
super.tearDown()
|
||||||
restoreDefaultSettings()
|
restoreDefaultSettings()
|
||||||
|
|
||||||
|
evaluationContext = null
|
||||||
|
debuggerContext = null
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun configureSettings(fileText: String) {
|
protected fun configureSettings(fileText: String) {
|
||||||
@@ -75,11 +80,11 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
|||||||
kotlinSettings.DEBUG_RENDER_DELEGATED_PROPERTIES = fileText.getValueForSetting("RENDER_DELEGATED_PROPERTIES", oldRenderDelegatedProperties)
|
kotlinSettings.DEBUG_RENDER_DELEGATED_PROPERTIES = fileText.getValueForSetting("RENDER_DELEGATED_PROPERTIES", oldRenderDelegatedProperties)
|
||||||
|
|
||||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||||
debuggerSettings.SKIP_SYNTHETIC_METHODS = fileText.getValueForSetting("SKIP_SYNTHETIC_METHODS", oldSettings.SKIP_SYNTHETIC_METHODS)
|
debuggerSettings.SKIP_SYNTHETIC_METHODS = fileText.getValueForSetting("SKIP_SYNTHETIC_METHODS", oldSettings!!.SKIP_SYNTHETIC_METHODS)
|
||||||
debuggerSettings.SKIP_CONSTRUCTORS = fileText.getValueForSetting("SKIP_CONSTRUCTORS", oldSettings.SKIP_CONSTRUCTORS)
|
debuggerSettings.SKIP_CONSTRUCTORS = fileText.getValueForSetting("SKIP_CONSTRUCTORS", oldSettings!!.SKIP_CONSTRUCTORS)
|
||||||
debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings.SKIP_CLASSLOADERS)
|
debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings!!.SKIP_CLASSLOADERS)
|
||||||
debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings.TRACING_FILTERS_ENABLED)
|
debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings!!.TRACING_FILTERS_ENABLED)
|
||||||
debuggerSettings.SKIP_GETTERS = fileText.getValueForSetting("SKIP_GETTERS", oldSettings.SKIP_GETTERS)
|
debuggerSettings.SKIP_GETTERS = fileText.getValueForSetting("SKIP_GETTERS", oldSettings!!.SKIP_GETTERS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean {
|
private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean {
|
||||||
@@ -99,11 +104,11 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
|||||||
KotlinDebuggerSettings.getInstance().DEBUG_RENDER_DELEGATED_PROPERTIES = oldRenderDelegatedProperties
|
KotlinDebuggerSettings.getInstance().DEBUG_RENDER_DELEGATED_PROPERTIES = oldRenderDelegatedProperties
|
||||||
|
|
||||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||||
debuggerSettings.SKIP_SYNTHETIC_METHODS = oldSettings.SKIP_SYNTHETIC_METHODS
|
debuggerSettings.SKIP_SYNTHETIC_METHODS = oldSettings!!.SKIP_SYNTHETIC_METHODS
|
||||||
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings.SKIP_CONSTRUCTORS
|
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings!!.SKIP_CONSTRUCTORS
|
||||||
debuggerSettings.SKIP_CLASSLOADERS = oldSettings.SKIP_CLASSLOADERS
|
debuggerSettings.SKIP_CLASSLOADERS = oldSettings!!.SKIP_CLASSLOADERS
|
||||||
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings.TRACING_FILTERS_ENABLED
|
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings!!.TRACING_FILTERS_ENABLED
|
||||||
debuggerSettings.SKIP_GETTERS = oldSettings.SKIP_GETTERS
|
debuggerSettings.SKIP_GETTERS = oldSettings!!.SKIP_GETTERS
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val dp: DebugProcessImpl
|
protected val dp: DebugProcessImpl
|
||||||
@@ -117,9 +122,6 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected var evaluationContext: EvaluationContextImpl by Delegates.notNull()
|
|
||||||
protected var debuggerContext: DebuggerContextImpl by Delegates.notNull()
|
|
||||||
|
|
||||||
protected fun initContexts(suspendContext: SuspendContextImpl) {
|
protected fun initContexts(suspendContext: SuspendContextImpl) {
|
||||||
evaluationContext = createEvaluationContext(suspendContext)
|
evaluationContext = createEvaluationContext(suspendContext)
|
||||||
debuggerContext = createDebuggerContext(suspendContext)
|
debuggerContext = createDebuggerContext(suspendContext)
|
||||||
|
|||||||
+16
-10
@@ -59,13 +59,7 @@ import kotlin.test.fail
|
|||||||
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
|
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
|
||||||
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
|
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
|
||||||
|
|
||||||
private val appender = object : AppenderSkeleton() {
|
private var appender: AppenderSkeleton? = null
|
||||||
override fun append(event: LoggingEvent?) {
|
|
||||||
println(event?.getRenderedMessage(), ProcessOutputTypes.SYSTEM)
|
|
||||||
}
|
|
||||||
override fun close() {}
|
|
||||||
override fun requiresLayout() = false
|
|
||||||
}
|
|
||||||
|
|
||||||
private var oldLogLevel: Level? = null
|
private var oldLogLevel: Level? = null
|
||||||
private var oldShowFqTypeNames = false
|
private var oldShowFqTypeNames = false
|
||||||
@@ -79,6 +73,15 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
|||||||
|
|
||||||
oldLogLevel = logger.getLevel()
|
oldLogLevel = logger.getLevel()
|
||||||
logger.setLevel(Level.DEBUG)
|
logger.setLevel(Level.DEBUG)
|
||||||
|
|
||||||
|
appender = object : AppenderSkeleton() {
|
||||||
|
override fun append(event: LoggingEvent?) {
|
||||||
|
println(event?.getRenderedMessage(), ProcessOutputTypes.SYSTEM)
|
||||||
|
}
|
||||||
|
override fun close() {}
|
||||||
|
override fun requiresLayout() = false
|
||||||
|
}
|
||||||
|
|
||||||
logger.addAppender(appender)
|
logger.addAppender(appender)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +89,9 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
|||||||
logger.setLevel(oldLogLevel)
|
logger.setLevel(oldLogLevel)
|
||||||
logger.removeAppender(appender)
|
logger.removeAppender(appender)
|
||||||
|
|
||||||
|
appender = null
|
||||||
|
oldLogLevel = null
|
||||||
|
|
||||||
NodeRendererSettings.getInstance()!!.getClassRenderer()!!.SHOW_FQ_TYPE_NAMES = oldShowFqTypeNames
|
NodeRendererSettings.getInstance()!!.getClassRenderer()!!.SHOW_FQ_TYPE_NAMES = oldShowFqTypeNames
|
||||||
|
|
||||||
super.tearDown()
|
super.tearDown()
|
||||||
@@ -195,7 +201,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getExtraVars(): Set<TextWithImports> {
|
fun getExtraVars(): Set<TextWithImports> {
|
||||||
return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext.getSourcePosition(), evaluationContext, hashSetOf())!!
|
return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext!!.getSourcePosition(), evaluationContext, hashSetOf())!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class Printer() {
|
private inner class Printer() {
|
||||||
@@ -223,11 +229,11 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
|||||||
is StackFrameDescriptor -> logDescriptor(descriptor, "$curIndent frame = $label\n")
|
is StackFrameDescriptor -> logDescriptor(descriptor, "$curIndent frame = $label\n")
|
||||||
is WatchItemDescriptor -> logDescriptor(descriptor, "$curIndent extra = ${descriptor.calcValueName()}\n")
|
is WatchItemDescriptor -> logDescriptor(descriptor, "$curIndent extra = ${descriptor.calcValueName()}\n")
|
||||||
is LocalVariableDescriptor -> logDescriptor(descriptor, "$curIndent local = $label"
|
is LocalVariableDescriptor -> logDescriptor(descriptor, "$curIndent local = $label"
|
||||||
+ " (sp = ${render(SourcePositionProvider.getSourcePosition(descriptor, myProject, debuggerContext))})\n")
|
+ " (sp = ${render(SourcePositionProvider.getSourcePosition(descriptor, myProject, debuggerContext!!))})\n")
|
||||||
is StaticDescriptor -> logDescriptor(descriptor, "$curIndent static = $label\n")
|
is StaticDescriptor -> logDescriptor(descriptor, "$curIndent static = $label\n")
|
||||||
is ThisDescriptorImpl -> logDescriptor(descriptor, "$curIndent this = $label\n")
|
is ThisDescriptorImpl -> logDescriptor(descriptor, "$curIndent this = $label\n")
|
||||||
is FieldDescriptor -> logDescriptor(descriptor, "$curIndent field = $label"
|
is FieldDescriptor -> logDescriptor(descriptor, "$curIndent field = $label"
|
||||||
+ " (sp = ${render(SourcePositionProvider.getSourcePosition(descriptor, myProject, debuggerContext))})\n")
|
+ " (sp = ${render(SourcePositionProvider.getSourcePosition(descriptor, myProject, debuggerContext!!))})\n")
|
||||||
else -> logDescriptor(descriptor, "$curIndent unknown = $label\n")
|
else -> logDescriptor(descriptor, "$curIndent unknown = $label\n")
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user