From 307ca80397ccfcb2d92fde209bc763fc6515da0b Mon Sep 17 00:00:00 2001 From: Alexey Merkulov Date: Tue, 5 Mar 2024 18:15:23 +0100 Subject: [PATCH] [debugger] Add check into tests for preserving suspend policy on breakpoint During implementation of IDEA-338723 suspend policy is switching from suspend-thread to suspend all. Without this switch, the suspend policy will be wrong. So now test can track possible regression. GitOrigin-RevId: fbaeb0ec9552e93053b9474cbb8a550186c4651b --- .../debugger/ExecutionWithDebuggerToolsTestCase.java | 3 +++ .../test/AbstractIrKotlinEvaluateExpressionTest.kt | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java index ee48572ef3a7..5411bdc99ed2 100644 --- a/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java +++ b/java/testFramework/src/com/intellij/debugger/ExecutionWithDebuggerToolsTestCase.java @@ -55,6 +55,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa protected static final int RATHER_LATER_INVOKES_N = 10; public DebugProcessImpl myDebugProcess; private final List myException = new SmartList<>(); + protected boolean myWasUsedOnlyDefaultSuspendPolicy = true; private static class InvokeRatherLaterRequest { private final DebuggerCommandImpl myDebuggerCommand; @@ -104,6 +105,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa myDebugProcess = null; myBreakpointProvider = null; myRatherLaterRequests.clear(); + myWasUsedOnlyDefaultSuspendPolicy = true; } catch (Throwable e) { addSuppressedException(e); @@ -462,6 +464,7 @@ public abstract class ExecutionWithDebuggerToolsTestCase extends ExecutionTestCa //breakpoint.setSuspend(!DebuggerSettings.SUSPEND_NONE.equals(suspendPolicy)); breakpoint.setSuspendPolicy(suspendPolicy); systemPrintln("SUSPEND_POLICY = " + suspendPolicy); + myWasUsedOnlyDefaultSuspendPolicy = false; } String condition = comment.readValue("Condition"); diff --git a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractIrKotlinEvaluateExpressionTest.kt b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractIrKotlinEvaluateExpressionTest.kt index 9f5260d400ba..b6ef32ed71c4 100644 --- a/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractIrKotlinEvaluateExpressionTest.kt +++ b/plugins/kotlin/jvm-debugger/test/test/org/jetbrains/kotlin/idea/debugger/test/AbstractIrKotlinEvaluateExpressionTest.kt @@ -26,6 +26,8 @@ import com.intellij.ui.treeStructure.Tree import com.intellij.xdebugger.XDebuggerTestUtil import com.intellij.xdebugger.impl.ui.tree.ValueMarkup import com.sun.jdi.ObjectReference +import com.sun.jdi.request.EventRequest +import junit.framework.TestCase import org.jetbrains.eval4j.ObjectValue import org.jetbrains.eval4j.Value import org.jetbrains.eval4j.jdi.asValue @@ -154,6 +156,11 @@ abstract class AbstractIrKotlinEvaluateExpressionTest : KotlinDescriptorTestCase for ((expression, expected, kind) in data.fragments) { mayThrow(expression) { + if (myWasUsedOnlyDefaultSuspendPolicy) { + // It would be more correct to extract the policy from the breakpoint declaration (in test), + // but it is not a very easy task + TestCase.assertEquals("Invalid suspend policy on breakpoint", EventRequest.SUSPEND_ALL, suspendPolicy, ) + } evaluate(this, expression, kind, expected) } }