From 0c95de9b4142c96b960c3ca6e536a9b867e38815 Mon Sep 17 00:00:00 2001 From: Aleksey Dobrynin Date: Thu, 17 Oct 2024 18:45:40 +0200 Subject: [PATCH] [Groovy] fix GroovyDebuggerTest (IDEA-327339) GitOrigin-RevId: da4d0f263837670d4fb2e788850c3b639414529c --- .../groovy/compiler/DebuggerMethods.java | 11 ++++--- .../groovy/compiler/GroovyDebuggerTest.java | 32 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/DebuggerMethods.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/DebuggerMethods.java index fd2ba9830756..ea6068b97c0a 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/DebuggerMethods.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/DebuggerMethods.java @@ -93,7 +93,7 @@ public interface DebuggerMethods extends CompilerMethods { .addLineBreakpoint(FileDocumentManager.getInstance().getDocument(file), line)); } - default SuspendContextImpl waitForBreakpoint() throws RuntimeException { + default void waitForBreakpoint() throws RuntimeException { getLogger().debug("waitForBreakpoint"); final Semaphore semaphore = new Semaphore(); semaphore.down(); @@ -117,7 +117,6 @@ public interface DebuggerMethods extends CompilerMethods { } SuspendContextImpl context = suspendManager.getPausedContext(); assertNotNull("too long process, terminated=" + process.getProcessHandler().isProcessTerminated(), context); - return context; } default void resume() { @@ -128,9 +127,11 @@ public interface DebuggerMethods extends CompilerMethods { } default SourcePosition getSourcePosition() { - final EvaluationContextImpl context = evaluationContext(); - Computable a = () -> ContextUtil.getSourcePosition(context); - return ApplicationManager.getApplication().runReadAction(a); + return managed(() -> { + final EvaluationContextImpl context = evaluationContext(); + Computable a = () -> ContextUtil.getSourcePosition(context); + return ApplicationManager.getApplication().runReadAction(a); + }); } default EvaluationContextImpl evaluationContext() { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.java index 3d5186b7aa25..a00ce84bd221 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.java @@ -273,24 +273,30 @@ public class GroovyDebuggerTest extends GroovyCompilerTestCase implements Debugg runDebugger(file, () -> { waitForBreakpoint(); - assert myClass.get().equals(getSourcePosition().getFile().getVirtualFile()); + assertEquals(myClass.get(), getSourcePosition().getFile().getVirtualFile()); eval("a", "2"); }); } - public void test_groovy_source_named_java_in_lib_source() throws IOException { + public void test_groovy_source_named_java_in_lib_source() { final TempDirTestFixtureImpl tempDir = new TempDirTestFixtureImpl(); EdtTestUtil.runInEdtAndWait(() -> { - disposeOnTearDown(() -> { - try { - tempDir.tearDown(); - } - catch (Exception e) { - throw new RuntimeException(e); - } - }); - tempDir.createFile("pkg/java.groovy", "class java {}"); - PsiTestUtil.addLibrary(getModule(), "lib", tempDir.getFile("").getPath(), ArrayUtil.EMPTY_STRING_ARRAY, new String[]{""}); + try { + tempDir.setUp(); + disposeOnTearDown(() -> { + try { + tempDir.tearDown(); + } + catch (Exception e) { + throw new RuntimeException(e); + } + }); + tempDir.createFile("pkg/java.groovy", "class java {}"); + PsiTestUtil.addLibrary(getModule(), "lib", tempDir.getFile("").getPath(), ArrayUtil.EMPTY_STRING_ARRAY, new String[]{""}); + } + catch (Exception e) { + throw new RuntimeException(e); + } }); ActionsKt.runReadAction(() -> { @@ -371,7 +377,7 @@ public class GroovyDebuggerTest extends GroovyCompilerTestCase implements Debugg addBreakpoint("module1/Scr.groovy", 0); runDebugger(scr, () -> { waitForBreakpoint(); - assert scr.equals(getSourcePosition().getFile()); + assertEquals(scr, getSourcePosition().getFile()); }); }