Drop state from debugger tests

This commit is contained in:
Nikolay Krasko
2015-06-05 22:11:12 +03:00
parent fa4fa3295d
commit fbd46a3ca3
2 changed files with 36 additions and 28 deletions
@@ -50,13 +50,15 @@ import org.jetbrains.kotlin.idea.util.application.runWriteAction
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes
import javax.swing.SwingUtilities
import kotlin.properties.Delegates
abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
private var oldSettings: DebuggerSettings by Delegates.notNull()
private var oldIsFilterForStdlibAlreadyAdded: Boolean by Delegates.notNull()
private var oldDisableKotlinInternalClasses: Boolean by Delegates.notNull()
private var oldRenderDelegatedProperties: Boolean by Delegates.notNull()
private var oldSettings: DebuggerSettings? = null
private var oldIsFilterForStdlibAlreadyAdded = false
private var oldDisableKotlinInternalClasses = false
private var oldRenderDelegatedProperties = false
protected var evaluationContext: EvaluationContextImpl? = null
protected var debuggerContext: DebuggerContextImpl? = null
override fun initApplication() {
super.initApplication()
@@ -66,6 +68,9 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
override fun tearDown() {
super.tearDown()
restoreDefaultSettings()
evaluationContext = null
debuggerContext = null
}
protected fun configureSettings(fileText: String) {
@@ -75,11 +80,11 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
kotlinSettings.DEBUG_RENDER_DELEGATED_PROPERTIES = fileText.getValueForSetting("RENDER_DELEGATED_PROPERTIES", oldRenderDelegatedProperties)
val debuggerSettings = DebuggerSettings.getInstance()!!
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_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings.SKIP_CLASSLOADERS)
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_SYNTHETIC_METHODS = fileText.getValueForSetting("SKIP_SYNTHETIC_METHODS", oldSettings!!.SKIP_SYNTHETIC_METHODS)
debuggerSettings.SKIP_CONSTRUCTORS = fileText.getValueForSetting("SKIP_CONSTRUCTORS", oldSettings!!.SKIP_CONSTRUCTORS)
debuggerSettings.SKIP_CLASSLOADERS = fileText.getValueForSetting("SKIP_CLASSLOADERS", oldSettings!!.SKIP_CLASSLOADERS)
debuggerSettings.TRACING_FILTERS_ENABLED = fileText.getValueForSetting("TRACING_FILTERS_ENABLED", oldSettings!!.TRACING_FILTERS_ENABLED)
debuggerSettings.SKIP_GETTERS = fileText.getValueForSetting("SKIP_GETTERS", oldSettings!!.SKIP_GETTERS)
}
private fun String.getValueForSetting(name: String, defaultValue: Boolean): Boolean {
@@ -99,11 +104,11 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() {
KotlinDebuggerSettings.getInstance().DEBUG_RENDER_DELEGATED_PROPERTIES = oldRenderDelegatedProperties
val debuggerSettings = DebuggerSettings.getInstance()!!
debuggerSettings.SKIP_SYNTHETIC_METHODS = oldSettings.SKIP_SYNTHETIC_METHODS
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings.SKIP_CONSTRUCTORS
debuggerSettings.SKIP_CLASSLOADERS = oldSettings.SKIP_CLASSLOADERS
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings.TRACING_FILTERS_ENABLED
debuggerSettings.SKIP_GETTERS = oldSettings.SKIP_GETTERS
debuggerSettings.SKIP_SYNTHETIC_METHODS = oldSettings!!.SKIP_SYNTHETIC_METHODS
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings!!.SKIP_CONSTRUCTORS
debuggerSettings.SKIP_CLASSLOADERS = oldSettings!!.SKIP_CLASSLOADERS
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings!!.TRACING_FILTERS_ENABLED
debuggerSettings.SKIP_GETTERS = oldSettings!!.SKIP_GETTERS
}
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) {
evaluationContext = createEvaluationContext(suspendContext)
debuggerContext = createDebuggerContext(suspendContext)
@@ -59,13 +59,7 @@ import kotlin.test.fail
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
private val appender = object : AppenderSkeleton() {
override fun append(event: LoggingEvent?) {
println(event?.getRenderedMessage(), ProcessOutputTypes.SYSTEM)
}
override fun close() {}
override fun requiresLayout() = false
}
private var appender: AppenderSkeleton? = null
private var oldLogLevel: Level? = null
private var oldShowFqTypeNames = false
@@ -79,6 +73,15 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
oldLogLevel = logger.getLevel()
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)
}
@@ -86,6 +89,9 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
logger.setLevel(oldLogLevel)
logger.removeAppender(appender)
appender = null
oldLogLevel = null
NodeRendererSettings.getInstance()!!.getClassRenderer()!!.SHOW_FQ_TYPE_NAMES = oldShowFqTypeNames
super.tearDown()
@@ -195,7 +201,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
}
fun getExtraVars(): Set<TextWithImports> {
return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext.getSourcePosition(), evaluationContext, hashSetOf())!!
return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext!!.getSourcePosition(), evaluationContext, hashSetOf())!!
}
private inner class Printer() {
@@ -223,11 +229,11 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
is StackFrameDescriptor -> logDescriptor(descriptor, "$curIndent frame = $label\n")
is WatchItemDescriptor -> logDescriptor(descriptor, "$curIndent extra = ${descriptor.calcValueName()}\n")
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 ThisDescriptorImpl -> logDescriptor(descriptor, "$curIndent this = $label\n")
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")
}
return false