Debugger: add tests (filter classloaders and constructors)
This commit is contained in:
@@ -561,6 +561,7 @@ fun main(args: Array<String>) {
|
||||
testClass(javaClass<AbstractKotlinSteppingTest>()) {
|
||||
model("debugger/tinyApp/src/stepInto", testMethod = "doStepIntoTest", testClassName = "StepInto")
|
||||
model("debugger/tinyApp/src/stepInto", testMethod = "doSmartStepIntoTest", testClassName = "SmartStepInto")
|
||||
model("debugger/tinyApp/src/filters", testMethod = "doStepIntoTest")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractKotlinEvaluateExpressionTest>()) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at skipClassloader.kt:7
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! skipClassloader.SkipClassloaderPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
skipClassloader.kt:6
|
||||
skipClassloader.kt:4
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,8 @@
|
||||
LineBreakpoint created at skipConstructors.kt:5
|
||||
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! skipConstructors.SkipConstructorsPackage
|
||||
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
skipConstructors.kt:4
|
||||
skipConstructors.kt:5
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -0,0 +1,18 @@
|
||||
package skipClassloader
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val loader = javaClass<A>().getClassLoader()!!
|
||||
try {
|
||||
//Breakpoint!
|
||||
val aaa = loader.loadClass("skipClassloader.A")
|
||||
}
|
||||
catch (e: ClassNotFoundException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class A
|
||||
|
||||
// TRACING_FILTERS_ENABLED: false
|
||||
// SKIP_CLASSLOADERS: true
|
||||
@@ -0,0 +1,15 @@
|
||||
package skipConstructors
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
//Breakpoint!
|
||||
A()
|
||||
val b = 1
|
||||
}
|
||||
|
||||
class A {
|
||||
{
|
||||
val a = 1
|
||||
}
|
||||
}
|
||||
|
||||
// SKIP_CONSTRUCTORS: true
|
||||
@@ -25,12 +25,31 @@ import com.intellij.debugger.DebuggerManagerEx
|
||||
import com.intellij.debugger.ui.breakpoints.LineBreakpoint
|
||||
import com.intellij.debugger.actions.MethodSmartStepTarget
|
||||
import com.intellij.debugger.engine.BasicStepMethodFilter
|
||||
import com.intellij.openapi.util.Computable
|
||||
import org.jetbrains.jet.plugin.refactoring.runReadAction
|
||||
import org.jetbrains.jet.InTextDirectivesUtils.*
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
import com.intellij.debugger.settings.DebuggerSettings
|
||||
|
||||
public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestCase() {
|
||||
private var oldSettings: DebuggerSettings by Delegates.notNull()
|
||||
|
||||
override fun initApplication() {
|
||||
super<KotlinDebuggerTestCase>.initApplication()
|
||||
saveDefaultSettings()
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
super<KotlinDebuggerTestCase>.tearDown()
|
||||
restoreDefaultSettings()
|
||||
}
|
||||
|
||||
protected fun doStepIntoTest(path: String) {
|
||||
val fileText = FileUtil.loadFile(File(path))
|
||||
|
||||
configureSettings(fileText)
|
||||
|
||||
createDebugProcess(path)
|
||||
onBreakpoint { stepInto() }
|
||||
finish()
|
||||
@@ -42,6 +61,24 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestCase() {
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun configureSettings(fileText: String) {
|
||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||
debuggerSettings.SKIP_CONSTRUCTORS = findStringWithPrefixes(fileText, "// SKIP_CONSTRUCTORS: ")?.toBoolean() ?: oldSettings.SKIP_CONSTRUCTORS
|
||||
debuggerSettings.SKIP_CLASSLOADERS = findStringWithPrefixes(fileText, "// SKIP_CLASSLOADERS: ")?.toBoolean() ?: oldSettings.SKIP_CLASSLOADERS
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = findStringWithPrefixes(fileText, "// TRACING_FILTERS_ENABLED: ")?.toBoolean() ?: oldSettings.TRACING_FILTERS_ENABLED
|
||||
}
|
||||
|
||||
private fun saveDefaultSettings() {
|
||||
oldSettings = DebuggerSettings.getInstance()!!.clone()
|
||||
}
|
||||
|
||||
private fun restoreDefaultSettings() {
|
||||
val debuggerSettings = DebuggerSettings.getInstance()!!
|
||||
debuggerSettings.SKIP_CONSTRUCTORS = oldSettings.SKIP_CONSTRUCTORS
|
||||
debuggerSettings.SKIP_CLASSLOADERS = oldSettings.SKIP_CLASSLOADERS
|
||||
debuggerSettings.TRACING_FILTERS_ENABLED = oldSettings.TRACING_FILTERS_ENABLED
|
||||
}
|
||||
|
||||
private val dp: DebugProcessImpl
|
||||
get() = getDebugProcess() ?: throw AssertionError("createLocalProcess() should be called before getDebugProcess()")
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({KotlinSteppingTestGenerated.StepInto.class, KotlinSteppingTestGenerated.SmartStepInto.class})
|
||||
@InnerTestClasses({KotlinSteppingTestGenerated.StepInto.class, KotlinSteppingTestGenerated.SmartStepInto.class, KotlinSteppingTestGenerated.Filters.class})
|
||||
public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
||||
@TestMetadata("idea/testData/debugger/tinyApp/src/stepInto")
|
||||
public static class StepInto extends AbstractKotlinSteppingTest {
|
||||
@@ -175,10 +175,29 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/debugger/tinyApp/src/filters")
|
||||
public static class Filters extends AbstractKotlinSteppingTest {
|
||||
public void testAllFilesPresentInFilters() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/filters"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("skipClassloader.kt")
|
||||
public void testSkipClassloader() throws Exception {
|
||||
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/skipClassloader.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("skipConstructors.kt")
|
||||
public void testSkipConstructors() throws Exception {
|
||||
doStepIntoTest("idea/testData/debugger/tinyApp/src/filters/skipConstructors.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("KotlinSteppingTestGenerated");
|
||||
suite.addTestSuite(StepInto.class);
|
||||
suite.addTestSuite(SmartStepInto.class);
|
||||
suite.addTestSuite(Filters.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user