PY-37580 Add unit test for stepping into in new thread

GitOrigin-RevId: 4e27a685170fe20201e1aeb579747f4f23d03628
This commit is contained in:
Andrey Lisin
2019-09-03 15:34:42 +00:00
committed by intellij-monorepo-bot
parent 1eb6c58d91
commit abd6ecef4d
4 changed files with 59 additions and 5 deletions
@@ -0,0 +1,23 @@
from __future__ import print_function
import threading
class A(threading.Thread):
def foo(self):
print("foo")
def bar(self):
print("bar")
def baz(self):
print("baz")
def run(self):
self.foo() # breakpoint
self.bar()
self.baz() # breakpoint
if __name__ == '__main__':
t = A()
t.start()
@@ -173,7 +173,7 @@ public abstract class PyExecutionFixtureTestTask extends PyTestTask {
protected String getFilePath(@NotNull final String path) {
final VirtualFile virtualFile = myFixture.getTempDirFixture().getFile(path);
assert virtualFile != null && virtualFile.exists() : String.format("No file in %s", myFixture.getTempDirPath());
assert virtualFile != null && virtualFile.exists() : String.format("No file '%s' in %s", path, myFixture.getTempDirPath());
return virtualFile.getPath();
}
@@ -2283,7 +2283,7 @@ public class PythonDebuggerTest extends PyEnvTestCase {
@Override
public void before() throws Exception {
toggleBreakpoint(getScriptName(), 8);
toggleBreakpoint(getFilePath(getScriptName()), 8);
}
@Override
@@ -2328,4 +2328,35 @@ public class PythonDebuggerTest extends PyEnvTestCase {
}
});
}
@Test
public void testStepIntoWithThreads() {
runPythonTest(new PyDebuggerTask("/debug", "test_step_into_with_threads.py") {
@Override
public void before() {
toggleBreakpoint(getFilePath(getScriptName()), 15);
toggleBreakpoint(getFilePath(getScriptName()), 17);
}
@Override
public void testing() throws Exception {
waitForPause();
stepInto();
waitForPause();
stepOver();
waitForPause();
waitForOutput("foo");
resume();
waitForOutput("bar");
waitForPause();
stepInto();
waitForPause();
stepOver();
waitForPause();
waitForOutput("baz");
resume();
waitForTerminate();
}
});
}
}
@@ -101,7 +101,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
protected void resume() {
XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession();
Assert.assertTrue(currentSession.isSuspended());
Assert.assertTrue("Resume called for session that is not in suspended state", currentSession.isSuspended());
Assert.assertEquals(0, myPausedSemaphore.availablePermits());
currentSession.resume();
@@ -110,7 +110,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
protected void stepOver() {
XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession();
Assert.assertTrue(currentSession.isSuspended());
Assert.assertTrue("Step over called for session that is not in suspended state", currentSession.isSuspended());
Assert.assertEquals(0, myPausedSemaphore.availablePermits());
currentSession.stepOver(false);
@@ -119,7 +119,7 @@ public abstract class PyBaseDebuggerTask extends PyExecutionFixtureTestTask {
protected void stepInto() {
XDebugSession currentSession = XDebuggerManager.getInstance(getProject()).getCurrentSession();
Assert.assertTrue(currentSession.isSuspended());
Assert.assertTrue("Step into called for session that is not in suspended state", currentSession.isSuspended());
Assert.assertEquals(0, myPausedSemaphore.availablePermits());
currentSession.stepInto();