protected void finishSession() throws InterruptedException {
    disposeDebugProcess();

    if (mySession != null) {
      new WriteAction() {
        protected void run(Result result) throws Throwable {
          mySession.stop();
        }
      }.execute();

      waitFor(
          mySession
              .getDebugProcess()
              .getProcessHandler()); // wait for process termination after session.stop() which is
      // async

      XDebuggerTestUtil.disposeDebugSession(mySession);

      mySession = null;
      myDebugProcess = null;
      myPausedSemaphore = null;
    }

    final ExecutionResult result = myExecutionResult;
    if (myExecutionResult != null) {
      UIUtil.invokeLaterIfNeeded(
          new Runnable() {
            @Override
            public void run() {
              Disposer.dispose(result.getExecutionConsole());
            }
          });
      myExecutionResult = null;
    }
  }
  protected void waitForTerminate() throws InterruptedException, InvocationTargetException {
    setProcessCanTerminate(true);

    Assert.assertTrue(
        "Debugger didn't terminated within timeout\nOutput:" + output(),
        waitFor(myTerminateSemaphore));
    XDebuggerTestUtil.waitForSwing();
  }
 @NotNull
 protected String output() {
   if (mySession != null && mySession.getConsoleView() != null) {
     PythonDebugLanguageConsoleView pydevConsoleView =
         (PythonDebugLanguageConsoleView) mySession.getConsoleView();
     return XDebuggerTestUtil.getConsoleText(pydevConsoleView.getTextConsole());
   }
   return "Console output not available.";
 }
  protected void waitForPause() throws InterruptedException, InvocationTargetException {
    Assert.assertTrue(
        "Debugger didn't stopped within timeout\nOutput:" + output(), waitFor(myPausedSemaphore));

    XDebuggerTestUtil.waitForSwing();
  }
 public Variable(XValue value) throws InterruptedException {
   myValueNode = XDebuggerTestUtil.computePresentation(value);
 }
 protected void setVal(String name, String value)
     throws InterruptedException, PyDebuggerException {
   XValue var = XDebuggerTestUtil.evaluate(mySession, name).first;
   myDebugProcess.changeVariable((PyDebugValue) var, value);
 }
 protected Variable eval(String name) throws InterruptedException {
   Assert.assertTrue("Eval works only while suspended", mySession.isSuspended());
   XValue var = XDebuggerTestUtil.evaluate(mySession, name).first;
   Assert.assertNotNull("There is no variable named " + name, var);
   return new Variable(var);
 }
 private void doToggleBreakpoint(String file, int line) {
   Assert.assertTrue(canPutBreakpointAt(getProject(), file, line));
   XDebuggerTestUtil.toggleBreakpoint(
       getProject(), LocalFileSystem.getInstance().findFileByPath(file), line);
 }
 public Pair<XValue, String> waitFor(long timeoutInMilliseconds) throws InterruptedException {
   Assert.assertTrue("timed out", XDebuggerTestUtil.waitFor(myFinished, timeoutInMilliseconds));
   return Pair.create(myResult, myErrorMessage);
 }