use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class DartRunner method doExecute.
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
final String executorId = env.getExecutor().getId();
if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)) {
LOG.error("Unexpected executor id: " + executorId);
return null;
}
try {
final String dasExecutionContextId;
final RunProfile runConfig = env.getRunProfile();
if (runConfig instanceof DartRunConfigurationBase && DartAnalysisServerService.getInstance(env.getProject()).serverReadyForRequest(env.getProject())) {
final String path = ((DartRunConfigurationBase) runConfig).getRunnerParameters().getFilePath();
// already checked
assert path != null;
dasExecutionContextId = DartAnalysisServerService.getInstance(env.getProject()).execution_createContext(path);
} else {
// remote debug or can't start DAS
dasExecutionContextId = null;
}
return doExecuteDartDebug(state, env, dasExecutionContextId);
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class DartCommandLineRunningState method setupParameters.
private void setupParameters(@NotNull final GeneralCommandLine commandLine, @Nullable final String overriddenMainFilePath) throws ExecutionException {
int customObservatoryPort = -1;
final String vmOptions = myRunnerParameters.getVMOptions();
if (vmOptions != null) {
final StringTokenizer vmOptionsTokenizer = new CommandLineTokenizer(vmOptions);
while (vmOptionsTokenizer.hasMoreTokens()) {
final String vmOption = vmOptionsTokenizer.nextToken();
commandLine.addParameter(vmOption);
try {
if (vmOption.equals("--enable-vm-service") || vmOption.equals("--observe")) {
// default port, see https://www.dartlang.org/tools/dart-vm/
customObservatoryPort = 8181;
} else if (vmOption.startsWith("--enable-vm-service:")) {
customObservatoryPort = parseIntBeforeSlash(vmOption.substring("--enable-vm-service:".length()));
} else if (vmOption.startsWith("--observe:")) {
customObservatoryPort = parseIntBeforeSlash(vmOption.substring("--observe:".length()));
}
} catch (NumberFormatException ignore) {
/**/
}
}
}
if (myRunnerParameters.isCheckedMode()) {
commandLine.addParameter(DartiumUtil.CHECKED_MODE_OPTION);
}
final VirtualFile dartFile;
try {
dartFile = myRunnerParameters.getDartFileOrDirectory();
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
if (DefaultDebugExecutor.EXECUTOR_ID.equals(getEnvironment().getExecutor().getId())) {
commandLine.addParameter("--pause_isolates_on_start");
}
if (customObservatoryPort > 0) {
myObservatoryPort = customObservatoryPort;
} else {
try {
myObservatoryPort = NetUtils.findAvailableSocketPort();
} catch (IOException e) {
throw new ExecutionException(e);
}
commandLine.addParameter("--enable-vm-service:" + myObservatoryPort);
if (getEnvironment().getRunner() instanceof DartCoverageProgramRunner) {
commandLine.addParameter("--pause-isolates-on-exit");
}
}
commandLine.addParameter(FileUtil.toSystemDependentName(overriddenMainFilePath == null ? dartFile.getPath() : overriddenMainFilePath));
final String arguments = myRunnerParameters.getArguments();
if (arguments != null) {
StringTokenizer argumentsTokenizer = new CommandLineTokenizer(arguments);
while (argumentsTokenizer.hasMoreTokens()) {
commandLine.addParameter(argumentsTokenizer.nextToken());
}
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class JstdRunProfileState method buildTestFileScope.
@NotNull
private static TestFileScope buildTestFileScope(@NotNull Project project, @NotNull JstdRunSettings settings) throws ExecutionException {
TestType testType = settings.getTestType();
if (testType == TestType.ALL_CONFIGS_IN_DIRECTORY || testType == TestType.CONFIG_FILE) {
return TestFileScope.allScope();
}
if (testType == TestType.JS_FILE) {
File jsFile = new File(settings.getJsFilePath());
if (jsFile.isAbsolute() && jsFile.isFile()) {
VirtualFile virtualFile = VfsUtil.findFileByIoFile(jsFile, true);
if (virtualFile != null) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile instanceof JSFile) {
JSFile jsPsiFile = (JSFile) psiFile;
TestFileStructurePack pack = TestFileStructureManager.fetchTestFileStructurePackByJsFile(jsPsiFile);
if (pack != null) {
List<String> testCases = pack.getTopLevelElements();
if (testCases.isEmpty()) {
throw new ExecutionException("No tests found in " + jsPsiFile.getName());
}
Map<String, Set<String>> scope = ContainerUtil.newHashMap();
for (String testCase : testCases) {
scope.put(testCase, Collections.emptySet());
}
return TestFileScope.customScope(scope);
}
}
}
}
throw new ExecutionException("Unable to extract tests from " + jsFile.getName());
}
if (testType == TestType.TEST_CASE) {
Map<String, Set<String>> scope = Collections.singletonMap(settings.getTestCaseName(), Collections.<String>emptySet());
return TestFileScope.customScope(scope);
}
if (testType == TestType.TEST_METHOD) {
Map<String, Set<String>> scope = Collections.singletonMap(settings.getTestCaseName(), Collections.singleton(settings.getTestMethodName()));
return TestFileScope.customScope(scope);
}
throw new RuntimeException("Unexpected test type: " + testType);
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class JstdRunProfileState method executeWithServer.
@NotNull
public ExecutionResult executeWithServer(@Nullable JstdServer ideServer) throws ExecutionException {
if (!myRunSettings.isExternalServerType() && ideServer == null) {
throw new ExecutionException("[Internal error] Local JsTestDriver server running in IDE not found");
}
ProcessHandler processHandler = createProcessHandler(ideServer);
ConsoleView consoleView = createSMTRunnerConsoleView(ideServer);
consoleView.attachToProcess(processHandler);
DefaultExecutionResult executionResult = new DefaultExecutionResult(consoleView, processHandler);
executionResult.setRestartActions(new ToggleAutoTestAction());
return executionResult;
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class JstdRunProgramRunner method execute.
@NotNull
@Override
protected Promise<RunContentDescriptor> execute(@NotNull ExecutionEnvironment environment, @NotNull RunProfileState state) throws ExecutionException {
JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
if (jstdState.getRunSettings().isExternalServerType()) {
return Promise.resolve(start(null, false, state, environment));
}
JstdToolWindowManager jstdToolWindowManager = JstdToolWindowManager.getInstance(environment.getProject());
jstdToolWindowManager.setAvailable(true);
JstdServer server = JstdServerRegistry.getInstance().getServer();
if (server != null && !server.isStopped()) {
return Promise.resolve(start(server, false, state, environment));
}
return jstdToolWindowManager.restartServer().thenAsync(it -> {
try {
return it == null ? null : Promises.resolvedPromise(start(it, false, state, environment));
} catch (ExecutionException e) {
return Promises.rejectedPromise(e);
}
});
}
Aggregations