use of com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties in project intellij-community by JetBrains.
the class JavaTestFrameworkRunnableState method execute.
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final RunnerSettings runnerSettings = getRunnerSettings();
final SMTRunnerConsoleProperties testConsoleProperties = getConfiguration().createTestConsoleProperties(executor);
testConsoleProperties.setIfUndefined(TestConsoleProperties.HIDE_PASSED_TESTS, false);
final BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(getFrameworkName(), testConsoleProperties);
final SMTestRunnerResultsForm viewer = ((SMTRunnerConsoleView) consoleView).getResultsViewer();
Disposer.register(getConfiguration().getProject(), consoleView);
final OSProcessHandler handler = createHandler(executor);
consoleView.attachToProcess(handler);
final AbstractTestProxy root = viewer.getRoot();
if (root instanceof TestProxyRoot) {
((TestProxyRoot) root).setHandler(handler);
}
handler.addProcessListener(new ProcessAdapter() {
@Override
public void startNotified(ProcessEvent event) {
if (getConfiguration().isSaveOutputToFile()) {
final File file = OutputFileUtil.getOutputFile(getConfiguration());
root.setOutputFilePath(file != null ? file.getAbsolutePath() : null);
}
}
@Override
public void processTerminated(ProcessEvent event) {
Runnable runnable = () -> {
root.flushOutputFile();
deleteTempFiles();
clear();
};
UIUtil.invokeLaterIfNeeded(runnable);
handler.removeProcessListener(this);
}
});
AbstractRerunFailedTestsAction rerunFailedTestsAction = testConsoleProperties.createRerunFailedTestsAction(consoleView);
LOG.assertTrue(rerunFailedTestsAction != null);
rerunFailedTestsAction.setModelProvider(() -> viewer);
final DefaultExecutionResult result = new DefaultExecutionResult(consoleView, handler);
result.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction() {
@Override
public boolean isDelayApplicable() {
return false;
}
@Override
public AbstractAutoTestManager getAutoTestManager(Project project) {
return JavaAutoRunManager.getInstance(project);
}
});
JavaRunConfigurationExtensionManager.getInstance().attachExtensionsToProcess(getConfiguration(), handler, runnerSettings);
return result;
}
use of com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties in project intellij-community by JetBrains.
the class AbstractImportTestsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
LOG.assertTrue(project != null);
final VirtualFile file = getFile(project);
if (file != null) {
try {
final ImportRunProfile profile = new ImportRunProfile(file, project);
SMTRunnerConsoleProperties properties = profile.getProperties();
if (properties == null) {
properties = myProperties;
LOG.info("Failed to detect test framework in " + file.getPath() + "; use " + (properties != null ? properties.getTestFrameworkName() + " from toolbar" : "no properties"));
}
final Executor executor = properties != null ? properties.getExecutor() : ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(project, executor, profile);
ExecutionTarget target = profile.getTarget();
if (target != null) {
builder = builder.target(target);
}
final RunConfiguration initialConfiguration = profile.getInitialConfiguration();
final ProgramRunner runner = initialConfiguration != null ? RunnerRegistry.getInstance().getRunner(executor.getId(), initialConfiguration) : null;
if (runner != null) {
builder = builder.runner(runner);
}
builder.buildAndExecute();
} catch (ExecutionException e1) {
Messages.showErrorDialog(project, e1.getMessage(), "Import Failed");
}
}
}
use of com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties in project intellij-community by JetBrains.
the class ImportedTestRunnableState method execute.
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
RunProfile configuration;
final String frameworkName;
if (properties != null) {
configuration = properties.getConfiguration();
frameworkName = properties.getTestFrameworkName();
} else {
configuration = myRunProfile;
frameworkName = "Import Test Results";
}
final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(), configuration, frameworkName, executor);
final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(), consoleProperties);
final JComponent component = console.getComponent();
AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
if (component instanceof TestFrameworkRunningModel) {
rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
if (rerunFailedTestsAction != null) {
rerunFailedTestsAction.setModelProvider(() -> (TestFrameworkRunningModel) component);
}
}
console.attachToProcess(handler);
final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
if (rerunFailedTestsAction != null) {
result.setRestartActions(rerunFailedTestsAction);
}
return result;
}
use of com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties in project intellij-plugins by JetBrains.
the class CucumberJavaRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
return new JavaApplicationCommandLineState<CucumberJavaRunConfiguration>(CucumberJavaRunConfiguration.this, env) {
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
final JavaRunConfigurationModule module = getConfigurationModule();
final int classPathType = JavaParameters.JDK_AND_CLASSES_AND_TESTS;
final String jreHome = CucumberJavaRunConfiguration.this.ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null;
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
JavaParametersUtil.configureConfiguration(params, CucumberJavaRunConfiguration.this);
String path = getSMRunnerPath();
params.getClassPath().add(path);
params.setMainClass(MAIN_CLASS_NAME);
for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
ext.updateJavaParameters(CucumberJavaRunConfiguration.this, params, getRunnerSettings());
}
final String glueValue = getGlue();
if (glueValue != null && !StringUtil.isEmpty(glueValue)) {
final String[] glues = glueValue.split(" ");
for (String glue : glues) {
if (!StringUtil.isEmpty(glue)) {
params.getProgramParametersList().addParametersString(" --glue " + glue);
}
}
}
File f = new File(myFilePath);
if (!f.isDirectory()) {
f = f.getParentFile();
}
params.getVMParametersList().addParametersString("-Dorg.jetbrains.run.directory=\"" + f.getAbsolutePath() + "\"");
params.getProgramParametersList().addParametersString("\"" + myFilePath + "\"");
return params;
}
@Nullable
private ConsoleView createConsole(@NotNull final Executor executor, ProcessHandler processHandler) throws ExecutionException {
// console view
final String testFrameworkName = "cucumber";
final CucumberJavaRunConfiguration runConfiguration = CucumberJavaRunConfiguration.this;
final SMTRunnerConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, testFrameworkName, executor);
return SMTestRunnerConnectionUtil.createAndAttachConsole(testFrameworkName, processHandler, consoleProperties);
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ProcessHandler processHandler = startProcess();
final ConsoleView console = createConsole(executor, processHandler);
return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
};
}
use of com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties in project intellij-plugins by JetBrains.
the class FlexBaseRunner method createFlexUnitRunnerConsole.
public static ExecutionConsole createFlexUnitRunnerConsole(Project project, ExecutionEnvironment env, ProcessHandler processHandler) throws ExecutionException {
FlexStackTraceFilter stackTraceFilter = new FlexStackTraceFilter(project);
SMTRunnerConsoleProperties consoleProps = new FlexUnitConsoleProperties((FlexUnitRunConfiguration) env.getRunProfile(), env);
consoleProps.addStackTraceFilter(stackTraceFilter);
BaseTestsOutputConsoleView consoleView = SMTestRunnerConnectionUtil.createAndAttachConsole("FlexUnit", processHandler, consoleProps);
consoleView.addMessageFilter(stackTraceFilter);
Disposer.register(project, consoleView);
return consoleView;
}
Aggregations