use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class GeneralCommandLineTest method winShellScriptQuoting.
@Test
public void winShellScriptQuoting() throws Exception {
assumeTrue(SystemInfo.isWindows);
String scriptPrefix = "my_script";
for (String scriptExt : new String[] { ".cmd", ".bat" }) {
File script = ExecUtil.createTempExecutableScript(scriptPrefix, scriptExt, "@echo %1\n");
String param = "a&b";
GeneralCommandLine commandLine = createCommandLine(script.getAbsolutePath(), param);
String text = commandLine.getPreparedCommandLine(Platform.WINDOWS);
assertEquals(commandLine.getExePath() + "\n" + StringUtil.wrapWithDoubleQuote(param), text);
try {
String output = execAndGetOutput(commandLine);
assertEquals(StringUtil.wrapWithDoubleQuote(param), output.trim());
} finally {
FileUtil.delete(script);
}
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class GeneralCommandLineTest method winShellQuotingWithExtraSwitch.
@Test
public void winShellQuotingWithExtraSwitch() throws Exception {
assumeTrue(SystemInfo.isWindows);
String param = "a&b";
GeneralCommandLine commandLine = createCommandLine(ExecUtil.getWindowsShellName(), "/D", "/C", "echo", param);
String output = execAndGetOutput(commandLine);
assertEquals(StringUtil.wrapWithDoubleQuote(param), output.trim());
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class DartCommandLineRunningState method doStartProcess.
protected ProcessHandler doStartProcess(@Nullable final String overriddenMainFilePath) throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine(overriddenMainFilePath);
// Workaround for "Observatory listening on ..." message that is concatenated (without line break) with the message following it
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine) {
@Override
public void coloredTextAvailable(@NotNull String text, @NotNull Key attributes) {
if (text.startsWith(DartConsoleFilter.OBSERVATORY_LISTENING_ON)) {
text += "\n";
}
super.coloredTextAvailable(text, attributes);
}
};
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(final ProcessEvent event, final Key outputType) {
final String prefix = DartConsoleFilter.OBSERVATORY_LISTENING_ON + "http://";
final String text = event.getText().trim();
if (text.startsWith(prefix)) {
processHandler.removeProcessListener(this);
final String url = "http://" + text.substring(prefix.length());
for (Consumer<String> consumer : myObservatoryUrlConsumers) {
consumer.consume(url);
}
}
}
});
// Check for and display any analysis errors when we launch a Dart app.
final Project project = getEnvironment().getProject();
try {
final DartRunConfiguration dartRunConfiguration = (DartRunConfiguration) getEnvironment().getRunProfile();
final VirtualFile launchFile = dartRunConfiguration.getRunnerParameters().getDartFileOrDirectory();
String launchTitle = "Analysis issues with " + dartRunConfiguration.getName();
DartExecutionHelper.displayIssues(project, launchFile, launchTitle, dartRunConfiguration.getIcon());
} catch (RuntimeConfigurationError error) {
DartExecutionHelper.clearIssueNotifications(project);
}
ProcessTerminatedListener.attach(processHandler, getEnvironment().getProject());
return processHandler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class JstdRunProfileState method createOSProcessHandler.
@NotNull
private KillableColoredProcessHandler createOSProcessHandler(@NotNull String serverUrl) throws ExecutionException {
Map<TestRunner.ParameterKey, String> params = createParameterMap(serverUrl);
GeneralCommandLine commandLine = createCommandLine(params);
KillableColoredProcessHandler processHandler = new KillableColoredProcessHandler(commandLine, true);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-plugins by JetBrains.
the class JstdRunProfileState method createCommandLine.
@NotNull
private static GeneralCommandLine createCommandLine(@NotNull Map<TestRunner.ParameterKey, String> parameters) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
// uncomment this if you want to debug jsTestDriver code in the test-runner process
//commandLine.addParameter("-Xdebug");
//commandLine.addParameter("-Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=y");
File file = new File(PathUtil.getJarPathForClass(JsTestDriverServer.class));
commandLine.withWorkDirectory(file.getParentFile());
commandLine.addParameter("-cp");
commandLine.addParameter(buildClasspath());
commandLine.addParameter(TestRunner.class.getName());
for (Map.Entry<TestRunner.ParameterKey, String> param : parameters.entrySet()) {
String keyValue = EscapeUtils.join(Arrays.asList(param.getKey().name().toLowerCase(Locale.ENGLISH), param.getValue()), '=');
commandLine.addParameter("--" + keyValue);
}
return commandLine;
}
Aggregations