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) {
//noinspection ConstantConditions
final JUnitConfiguration configuration = (JUnitConfiguration) myConsoleProperties.getConfiguration();
final TestMethods testMethods = new TestMethods(configuration, environment, getFailedTests(configuration.getProject()));
return new MyRunProfile(configuration) {
@Override
@NotNull
public Module[] getModules() {
return testMethods.getModulesToCompile();
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
testMethods.clear();
return testMethods;
}
};
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class JUnitClasspathTest method testWorkingDirsFileWhenConfigurationSpansToMultipleModules.
public void testWorkingDirsFileWhenConfigurationSpansToMultipleModules() throws Exception {
final Module mod1 = setupModule("mod1", "T1");
final Module mod2 = setupModule("mod2", "T2");
final JUnitConfiguration configuration = new JUnitConfiguration("p", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
configuration.setWorkingDirectory("$MODULE_DIR$");
final JUnitConfiguration.Data persistentData = configuration.getPersistentData();
persistentData.setScope(TestSearchScope.SINGLE_MODULE);
configuration.setModule(mod1);
persistentData.PACKAGE_NAME = "p";
persistentData.TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
final ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build();
final TestPackage aPackage = new TestPackage(configuration, environment) {
@Override
protected boolean createTempFiles() {
return true;
}
};
//ensure no fork if single module is selected
aPackage.createSearchingForTestsTask().startSearch();
File workingDirsFile = aPackage.getWorkingDirsFile();
assertNotNull(workingDirsFile);
assertEmpty(FileUtil.loadFile(workingDirsFile));
//ensure fork when whole project is used
persistentData.setScope(TestSearchScope.WHOLE_PROJECT);
aPackage.createSearchingForTestsTask().startSearch();
workingDirsFile = aPackage.getWorkingDirsFile();
assertNotNull(workingDirsFile);
String file;
aPackage.createSearchingForTestsTask().startSearch();
workingDirsFile = aPackage.getWorkingDirsFile();
assertNotNull(workingDirsFile);
file = preparePathsForComparison(FileUtil.loadFile(workingDirsFile), mod1, mod2);
assertEquals("p\n" + "MODULE_1\n" + "mod1\n" + "CLASSPATH\n" + "1\n" + "p.T1\n" + "MODULE_2\n" + "mod2\n" + "CLASSPATH\n" + "1\n" + "p.T2", file);
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class JUnitClasspathTest method testNoWorkingDirsFileWhenOnlyOneModuleExist.
public void testNoWorkingDirsFileWhenOnlyOneModuleExist() throws Exception {
setupModule("mod1", "T1");
final JUnitConfiguration configuration = new JUnitConfiguration("p", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
configuration.setWorkingDirectory("$MODULE_DIR$");
final JUnitConfiguration.Data persistentData = configuration.getPersistentData();
persistentData.setScope(TestSearchScope.WHOLE_PROJECT);
persistentData.PACKAGE_NAME = "p";
persistentData.TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
final ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build();
final TestPackage aPackage = new TestPackage(configuration, environment);
aPackage.createSearchingForTestsTask().startSearch();
final File workingDirsFile = aPackage.getWorkingDirsFile();
assertNotNull(workingDirsFile);
assertEmpty(FileUtil.loadFile(workingDirsFile));
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class DebuggerTestCase method createLocalProcess.
protected DebuggerSession createLocalProcess(int transport, final JavaParameters javaParameters) throws ExecutionException, InterruptedException, InvocationTargetException {
createBreakpoints(javaParameters.getMainClass());
final DebuggerSession[] debuggerSession = new DebuggerSession[] { null };
DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = transport;
GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
debuggerRunnerSettings.LOCAL = true;
debuggerRunnerSettings.setDebugPort(String.valueOf(DEFAULT_ADDRESS));
ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()).runnerSettings(debuggerRunnerSettings).runProfile(new MockConfiguration()).build();
final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(environment) {
@Override
protected JavaParameters createJavaParameters() {
return javaParameters;
}
@Override
protected GeneralCommandLine createCommandLine() throws ExecutionException {
return getJavaParameters().toCommandLine();
}
};
final RemoteConnection debugParameters = DebuggerManagerImpl.createDebugParameters(javaCommandLineState.getJavaParameters(), debuggerRunnerSettings, true);
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
debuggerSession[0] = attachVirtualMachine(javaCommandLineState, javaCommandLineState.getEnvironment(), debugParameters, false);
} catch (ExecutionException e) {
fail(e.getMessage());
}
}
});
final ProcessHandler processHandler = debuggerSession[0].getProcess().getProcessHandler();
debuggerSession[0].getProcess().addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
print(event.getText(), outputType);
}
});
DebugProcessImpl process = (DebugProcessImpl) DebuggerManagerEx.getInstanceEx(myProject).getDebugProcess(processHandler);
assertNotNull(process);
return debuggerSession[0];
}
use of com.intellij.execution.runners.ExecutionEnvironment in project intellij-community by JetBrains.
the class ExternalSystemUtil method createExecutionEnvironment.
@Nullable
public static ExecutionEnvironment createExecutionEnvironment(@NotNull Project project, @NotNull ProjectSystemId externalSystemId, @NotNull ExternalSystemTaskExecutionSettings taskSettings, @NotNull String executorId) {
Executor executor = ExecutorRegistry.getInstance().getExecutorById(executorId);
if (executor == null)
return null;
String runnerId = getRunnerId(executorId);
if (runnerId == null)
return null;
ProgramRunner runner = RunnerRegistry.getInstance().findRunnerById(runnerId);
if (runner == null)
return null;
RunnerAndConfigurationSettings settings = createExternalSystemRunnerAndConfigurationSettings(taskSettings, project, externalSystemId);
if (settings == null)
return null;
return new ExecutionEnvironment(executor, runner, settings, project);
}
Aggregations