use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class AbstractRerunFailedTestsAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
ExecutionEnvironment environment = e.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
if (environment == null) {
return;
}
execute(e, environment);
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class RerunFailedTestsAction method getAction.
private static boolean getAction(@NotNull AnActionEvent e, boolean execute) {
Project project = e.getProject();
if (project == null) {
return false;
}
RunContentDescriptor contentDescriptor = ExecutionManager.getInstance(project).getContentManager().getSelectedContent();
if (contentDescriptor == null) {
return false;
}
JComponent component = contentDescriptor.getComponent();
if (component == null) {
return false;
}
ExecutionEnvironment environment = LangDataKeys.EXECUTION_ENVIRONMENT.getData(DataManager.getInstance().getDataContext(component));
if (environment == null) {
return false;
}
AnAction[] actions = contentDescriptor.getRestartActions();
if (actions.length == 0) {
return false;
}
for (AnAction action : actions) {
if (action instanceof AbstractRerunFailedTestsAction) {
if (execute) {
((AbstractRerunFailedTestsAction) action).execute(e, environment);
}
return true;
}
}
return false;
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class GradleRerunFailedTestsAction method getRunProfile.
@Nullable
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@NotNull
@Override
public Module[] getModules() {
return Module.EMPTY_ARRAY;
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
ExternalSystemRunConfiguration runProfile = ((ExternalSystemRunConfiguration) getPeer()).clone();
Project project = runProfile.getProject();
Set<String> scriptParameters = ContainerUtil.newLinkedHashSet();
Set<String> tasksToRun = ContainerUtil.newLinkedHashSet();
boolean useResolvedTasks = true;
for (AbstractTestProxy test : failedTests) {
if (test instanceof GradleSMTestProxy) {
String testName = test.getName();
String className = ((GradleSMTestProxy) test).getClassName();
scriptParameters.add(TestMethodGradleConfigurationProducer.createTestFilter(className, testName));
if (!useResolvedTasks)
continue;
if (className == null) {
useResolvedTasks = false;
continue;
}
final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.projectScope(project));
if (psiClass == null) {
useResolvedTasks = false;
continue;
}
final PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
useResolvedTasks = false;
continue;
}
final Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(psiFile.getVirtualFile());
if (moduleForFile == null) {
useResolvedTasks = false;
continue;
}
ContainerUtil.addAllNotNull(tasksToRun, GradleTestRunConfigurationProducer.getTasksToRun(moduleForFile));
}
}
runProfile.getSettings().setScriptParameters(StringUtil.join(scriptParameters, " "));
if (useResolvedTasks && !tasksToRun.isEmpty()) {
runProfile.getSettings().setTaskNames(ContainerUtil.newArrayList(tasksToRun));
}
return runProfile.getState(executor, environment);
}
};
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class RerunFailedTestsAction method getRunProfile.
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
final TestNGConfiguration configuration = (TestNGConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@Override
@NotNull
public Module[] getModules() {
return configuration.getModules();
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
return new TestNGRunnableState(env, configuration) {
@Override
public SearchingForTestsTask createSearchingForTestsTask() {
return new SearchingForTestsTask(myServerSocket, getConfiguration(), myTempFile) {
@Override
protected void fillTestObjects(final Map<PsiClass, Map<PsiMethod, List<String>>> classes) throws CantRunException {
final HashMap<PsiClass, Map<PsiMethod, List<String>>> fullClassList = ContainerUtil.newHashMap();
super.fillTestObjects(fullClassList);
for (final PsiClass aClass : fullClassList.keySet()) {
if (!ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return TestNGUtil.hasTest(aClass);
}
})) {
classes.put(aClass, fullClassList.get(aClass));
}
}
final GlobalSearchScope scope = getConfiguration().getConfigurationModule().getSearchScope();
final Project project = getConfiguration().getProject();
for (final AbstractTestProxy proxy : failedTests) {
ApplicationManager.getApplication().runReadAction(() -> includeFailedTestWithDependencies(classes, scope, project, proxy));
}
}
};
}
};
}
};
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class MavenRunConfigurationType method runConfiguration.
public static void runConfiguration(Project project, @NotNull MavenRunnerParameters params, @Nullable MavenGeneralSettings settings, @Nullable MavenRunnerSettings runnerSettings, @Nullable ProgramRunner.Callback callback) {
RunnerAndConfigurationSettings configSettings = createRunnerAndConfigurationSettings(settings, runnerSettings, params, project);
ProgramRunner runner = DefaultJavaProgramRunner.getInstance();
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
try {
runner.execute(new ExecutionEnvironment(executor, runner, configSettings, project), callback);
} catch (ExecutionException e) {
MavenUtil.showError(project, "Failed to execute Maven goal", e);
}
}
Aggregations