Search in sources :

Example 1 with TestResultsViewer

use of com.intellij.execution.testframework.sm.runner.ui.TestResultsViewer in project intellij-community by JetBrains.

the class PyUnitTestTask method runConfiguration.

/**
   * Run configuration.
   *
   * @param settings settings (if have any, null otherwise)
   * @param config   configuration to run
   * @throws Exception
   */
protected void runConfiguration(@Nullable final RunnerAndConfigurationSettings settings, @NotNull final RunConfiguration config) throws Exception {
    final ExecutionEnvironment environment;
    if (settings == null) {
        environment = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), config).build();
    } else {
        environment = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), settings).build();
    }
    //noinspection ConstantConditions
    Assert.assertTrue(environment.getRunner().canRun(DefaultRunExecutor.EXECUTOR_ID, config));
    before();
    final com.intellij.util.concurrency.Semaphore s = new com.intellij.util.concurrency.Semaphore();
    s.down();
    myOutput = new StringBuilder();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {

        @Override
        public void run() {
            try {
                environment.getRunner().execute(environment, new ProgramRunner.Callback() {

                    @Override
                    public void processStarted(RunContentDescriptor descriptor) {
                        myDescriptor = descriptor;
                        myProcessHandler = myDescriptor.getProcessHandler();
                        myProcessHandler.addProcessListener(new ProcessAdapter() {

                            @Override
                            public void onTextAvailable(ProcessEvent event, Key outputType) {
                                myOutput.append(event.getText());
                            }
                        });
                        myConsoleView = (SMTRunnerConsoleView) descriptor.getExecutionConsole();
                        myTestProxy = myConsoleView.getResultsViewer().getTestsRootNode();
                        myConsoleView.getResultsViewer().addEventsListener(new TestResultsViewer.SMEventsAdapter() {

                            @Override
                            public void onTestingFinished(TestResultsViewer sender) {
                                s.up();
                            }
                        });
                    }
                });
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    });
    Assert.assertTrue(s.waitFor(getTestTimeout()));
    XDebuggerTestUtil.waitForSwing();
    assertFinished();
    Assert.assertTrue(output(), allTestsCount() > 0);
    after();
    disposeProcess(myProcessHandler);
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) TestResultsViewer(com.intellij.execution.testframework.sm.runner.ui.TestResultsViewer) Key(com.intellij.openapi.util.Key)

Aggregations

ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 TestResultsViewer (com.intellij.execution.testframework.sm.runner.ui.TestResultsViewer)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 Key (com.intellij.openapi.util.Key)1