use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class KarmaExecutionSession method findTopLevelSuiteNames.
private static List<String> findTopLevelSuiteNames(@NotNull Project project, @NotNull String testFilePath) throws ExecutionException {
VirtualFile file = LocalFileFinder.findFile(testFilePath);
if (file == null) {
throw new ExecutionException("Cannot find test file by " + testFilePath);
}
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
JSFile jsFile = ObjectUtils.tryCast(psiFile, JSFile.class);
if (jsFile == null) {
LOG.info("Not a JavaScript file " + testFilePath + ", " + (psiFile == null ? "null" : psiFile.getClass()));
throw new ExecutionException("Not a JavaScript file: " + testFilePath);
}
JasmineFileStructure jasmine = JasmineFileStructureBuilder.getInstance().fetchCachedTestFileStructure(jsFile);
List<String> elements = jasmine.getTopLevelElements();
if (!elements.isEmpty()) {
return elements;
}
QUnitFileStructure qunit = QUnitFileStructureBuilder.getInstance().fetchCachedTestFileStructure(jsFile);
elements = qunit.getTopLevelElements();
if (!elements.isEmpty()) {
return elements;
}
throw new ExecutionException("No tests found in " + testFilePath);
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class KarmaExecutionSession method createProcessHandler.
@NotNull
private ProcessHandler createProcessHandler(@NotNull final KarmaServer server) throws ExecutionException {
final File clientAppFile;
try {
clientAppFile = server.getKarmaJsSourcesLocator().getClientAppFile();
} catch (IOException e) {
throw new ExecutionException("Can't find karma-intellij test runner", e);
}
if (server.areBrowsersReady()) {
return createOSProcessHandler(server, clientAppFile);
}
final NopProcessHandler nopProcessHandler = new NopProcessHandler();
terminateOnServerShutdown(server, nopProcessHandler);
return nopProcessHandler;
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class SendToMayaCommand method run.
public void run() {
try {
final ProcessHandler process = createRunInMayaProcessHandler();
new RunContentExecutor(myProject, process).withTitle(getTitle()).withRerun(() -> this.run()).withStop(() -> process.destroyProcess(), () -> !process.isProcessTerminated()).run();
} catch (ExecutionException e) {
Messages.showErrorDialog(myProject, e.getMessage(), getTitle());
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class SendToMayaCommand method createRunInMayaProcessHandler.
private ProcessHandler createRunInMayaProcessHandler() throws ExecutionException {
try {
final Socket socket = new Socket("127.0.0.1", myPythonCommandPort);
final SocketProcessHandler processHandler = new SocketProcessHandler(socket, getTitle());
try {
PrintWriter writer = new PrintWriter(new BufferedOutputStream(socket.getOutputStream()));
if (myScriptText != null) {
String[] lines = getScriptLines();
writeLines(writer, lines);
processHandler.notifyTextAvailable("Sent " + lines.length + " line" + (lines.length != 1 ? "s" : "") + " to command port " + myPythonCommandPort + "\n", ProcessOutputTypes.SYSTEM);
} else {
writeFile(writer, myFile);
processHandler.notifyTextAvailable("Sent " + myFile.getPath() + " to command port " + myPythonCommandPort + "\n", ProcessOutputTypes.SYSTEM);
}
writer.flush();
} catch (Exception e) {
if (!socket.isClosed()) {
socket.close();
}
throw new ExecutionException(e.getMessage());
}
return processHandler;
} catch (Exception e) {
throw new ExecutionException(e.getMessage());
}
}
use of com.intellij.execution.ExecutionException in project intellij-plugins by JetBrains.
the class KarmaServer method startServer.
private KillableColoredProcessHandler startServer(@NotNull KarmaServerSettings serverSettings) throws IOException {
GeneralCommandLine commandLine = new GeneralCommandLine();
serverSettings.getEnvData().configureCommandLine(commandLine, true);
commandLine.withWorkDirectory(serverSettings.getConfigurationFile().getParentFile());
commandLine.setExePath(serverSettings.getNodeInterpreter().getInterpreterSystemDependentPath());
File serverFile = myKarmaJsSourcesLocator.getServerAppFile();
//NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 34598, true,
// serverSettings.getNodeInterpreter(), true);
commandLine.addParameter(serverFile.getAbsolutePath());
commandLine.addParameter("--karmaPackageDir=" + myServerSettings.getKarmaPackage().getSystemDependentPath());
commandLine.addParameter("--configFile=" + serverSettings.getConfigurationFilePath());
String browsers = serverSettings.getBrowsers();
if (!StringUtil.isEmptyOrSpaces(browsers)) {
commandLine.addParameter("--browsers=" + browsers);
}
if (myCoveragePeer != null) {
commandLine.addParameter("--coverageTempDir=" + myCoveragePeer.getCoverageTempDir());
}
if (serverSettings.isDebug()) {
commandLine.addParameter("--debug=true");
}
commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
KillableColoredProcessHandler processHandler;
try {
processHandler = new KillableColoredProcessHandler(commandLine);
} catch (ExecutionException e) {
throw new IOException("Can not start Karma server: " + commandLine.getCommandLineString(), e);
}
final int processHashCode = System.identityHashCode(processHandler.getProcess());
LOG.info("Karma server " + processHashCode + " started successfully: " + commandLine.getCommandLineString());
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(final ProcessEvent event) {
LOG.info("Karma server " + processHashCode + " terminated with exit code " + event.getExitCode());
Disposer.dispose(myDisposable);
fireOnTerminated(event.getExitCode());
}
});
ProcessTerminatedListener.attach(processHandler);
processHandler.setShouldDestroyProcessRecursively(true);
return processHandler;
}
Aggregations