[Groovy] fix GroovyDebuggerTest (IDEA-327339)

GitOrigin-RevId: da4d0f263837670d4fb2e788850c3b639414529c
This commit is contained in:
Aleksey Dobrynin
2024-10-17 21:10:53 +00:00
committed by intellij-monorepo-bot
parent 9e9ef59c7b
commit 0c95de9b41
2 changed files with 25 additions and 18 deletions
@@ -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<SourcePosition> a = () -> ContextUtil.getSourcePosition(context);
return ApplicationManager.getApplication().runReadAction(a);
return managed(() -> {
final EvaluationContextImpl context = evaluationContext();
Computable<SourcePosition> a = () -> ContextUtil.getSourcePosition(context);
return ApplicationManager.getApplication().runReadAction(a);
});
}
default EvaluationContextImpl evaluationContext() {
@@ -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());
});
}