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);
}
Aggregations