com.intellij.execution.configurations.GeneralCommandLine Java Examples

The following examples show how to use com.intellij.execution.configurations.GeneralCommandLine. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReactiveTfvcClientHost.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
public static ReactiveTfvcClientHost create(Project project, Path clientPath) throws ExecutionException {
    SingleThreadScheduler scheduler = new SingleThreadScheduler(defineNestedLifetime(project), "ReactiveTfClient Scheduler");
    ReactiveClientConnection connection = new ReactiveClientConnection(scheduler);
    try {
        Path logDirectory = Paths.get(PathManager.getLogPath(), "ReactiveTfsClient");
        Path clientHomeDir = clientPath.getParent().getParent();
        GeneralCommandLine commandLine = ProcessHelper.patchPathEnvironmentVariable(
                getClientCommandLine(clientPath, connection.getPort(), logDirectory, clientHomeDir));
        ProcessHandler processHandler = new OSProcessHandler(commandLine);
        connection.getLifetime().onTerminationIfAlive(processHandler::destroyProcess);

        processHandler.addProcessListener(createProcessListener(connection));
        processHandler.startNotify();

        return new ReactiveTfvcClientHost(connection);
    } catch (Throwable t) {
        connection.terminate();
        throw t;
    }
}
 
Example #2
Source File: NativeFileType.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean openAssociatedApplication(@Nonnull final VirtualFile file) {
  final List<String> commands = new ArrayList<>();
  if (SystemInfo.isWindows) {
    commands.add("rundll32.exe");
    commands.add("url.dll,FileProtocolHandler");
  }
  else if (SystemInfo.isMac) {
    commands.add("/usr/bin/open");
  }
  else if (SystemInfo.hasXdgOpen()) {
    commands.add("xdg-open");
  }
  else {
    return false;
  }
  commands.add(file.getPath());

  try {
    new GeneralCommandLine(commands).createProcess();
    return true;
  }
  catch (Exception e) {
    return false;
  }
}
 
Example #3
Source File: FreeRunConfiguration.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private ExecutionResult buildExecutionResult() throws ExecutionException {
    GeneralCommandLine commandLine = createDefaultCommandLine();
    ProcessHandler processHandler = createProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    ConsoleView console = new TerminalExecutionConsole(getProject(), processHandler);

    console.print(
        "Welcome to React Native Console, now please click one button on top toolbar to start.\n",
        ConsoleViewContentType.SYSTEM_OUTPUT);
    console.attachToProcess(processHandler);

    console.print(
        "Give a Star or Suggestion:\n",
        ConsoleViewContentType.NORMAL_OUTPUT);


    processHandler.destroyProcess();
    return new DefaultExecutionResult(console, processHandler);
}
 
Example #4
Source File: RedisConsoleRunner.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected Process createProcess() throws ExecutionException {

    NoSqlConfiguration noSqlConfiguration = NoSqlConfiguration.getInstance(getProject());
    String shellPath = noSqlConfiguration.getShellPath(DatabaseVendor.REDIS);
    final GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(shellPath);

    commandLine.addParameter("-n");
    commandLine.addParameter(database.getName());

    String shellWorkingDir = serverConfiguration.getShellWorkingDir();
    if (StringUtils.isNotBlank(shellWorkingDir)) {
        commandLine.setWorkDirectory(shellWorkingDir);
    }

    String shellArgumentsLine = serverConfiguration.getShellArgumentsLine();
    if (StringUtils.isNotBlank(shellArgumentsLine)) {
        commandLine.addParameters(shellArgumentsLine.split(" "));
    }

    return commandLine.createProcess();
}
 
Example #5
Source File: CliBuilder.java    From eslint-plugin with MIT License 6 votes vote down vote up
@NotNull
static GeneralCommandLine createLint(@NotNull ESLintRunner.ESLintSettings settings) {
    GeneralCommandLine commandLine = create(settings);
    // TODO validate arguments (file exist etc)
    commandLine.addParameter(settings.targetFile);
    CLI.addParamIfNotEmpty(commandLine, C, settings.config);
    if (StringUtil.isNotEmpty(settings.rules)) {
        CLI.addParam(commandLine, RULESDIR, "['" + settings.rules + "']");
    }
    if (StringUtil.isNotEmpty(settings.ext)) {
        CLI.addParam(commandLine, EXT, settings.ext);
    }
    if (settings.fix) {
        commandLine.addParameter(FIX);
    }
    if (settings.reportUnused) {
        commandLine.addParameter(REPORT_UNUSED);
    }
    CLI.addParam(commandLine, FORMAT, JSON);
    return commandLine;
}
 
Example #6
Source File: ExecUtil.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
/**
 * Tries to get the absolute path for a command in the PATH.
 */
@Nullable
public static String locateExecutable(@NotNull final String exePath) {
    GeneralCommandLine cmdLine = new GeneralCommandLine(
        SystemInfo.isWindows ? "where" : "which"
    );
    cmdLine.addParameter(exePath);
    final ProcessOutput processOutput;
    try {
        processOutput = new CapturingProcessHandler(cmdLine).runProcess();
    } catch (ExecutionException e) {
        throw new RuntimeException(
            "Failed to execute command: " + cmdLine.getCommandLineString(),
            e
        );
    }
    final String stdout = processOutput.getStdout();
    final String[] lines = stdout.trim().split("\n");
    if (lines.length == 0) return null;
    return lines[0].trim();
}
 
Example #7
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineForTestNameInDebugMode() throws ExecutionException {
  final BazelTestFields fields = forTestName("first test", "/workspace/foo/test/foo_test.dart");
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.DEBUG);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/flutter-test.sh");
  expectedCommandLine.add("--no-color");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("--name");
  expectedCommandLine.add("first test");
  expectedCommandLine.add("foo/test/foo_test.dart");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--enable-debugging");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #8
Source File: MongoCommandLineState.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
private GeneralCommandLine generateCommandLine() {
    final GeneralCommandLine commandLine = new GeneralCommandLine();

    String exePath = mongoRunConfiguration.getMongoShell();
    commandLine.setExePath(exePath);

    ServerConfiguration serverConfiguration = mongoRunConfiguration.getServerConfiguration();
    MongoDatabase database = mongoRunConfiguration.getDatabase();
    commandLine.addParameter(MongoUtils.buildMongoUrl(serverConfiguration, database));

    VirtualFile scriptPath = mongoRunConfiguration.getScriptPath();
    commandLine.addParameter(scriptPath.getPath());


    String shellWorkingDir = mongoRunConfiguration.getShellWorkingDir();
    if (StringUtils.isNotEmpty(shellWorkingDir)) {
        commandLine.setWorkDirectory(shellWorkingDir);
    }
    return commandLine;
}
 
Example #9
Source File: NodeRunner.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param cwd working directory
 * @param node node interpreter path
 * @param exe node executable to run
 * @return command line to sdk
 */
@NotNull
public static GeneralCommandLine createCommandLine(@NotNull String cwd, String node, String exe) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    if (!new File(cwd).exists()) {
        throw new IllegalArgumentException("cwd: "+cwd +" doesn't exist");
    }
    if (!new File(exe).exists()) {
        throw new IllegalArgumentException("exe: "+exe +" doesn't exist");

    }
    commandLine.setWorkDirectory(cwd);
    if (SystemInfo.isWindows) {
        commandLine.setExePath(exe);
    } else {
        if (!new File(node).exists()) {
            throw new IllegalArgumentException("path doesn't exist");
        }
        commandLine.setExePath(node);
        commandLine.addParameter(exe);
    }
    return commandLine;
}
 
Example #10
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineWithAndroidEmulator() throws ExecutionException {
  final BazelFields fields = setupBazelFields();

  final FlutterDevice device = new FlutterDevice("android-tester", "android device", "android", true);
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("android-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #11
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineWithIosDevice() throws ExecutionException {
  final BazelFields fields = setupBazelFields();

  final FlutterDevice device = new FlutterDevice("ios-tester", "ios device", "ios", false);
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("--ios_multi_cpus=arm64");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("ios-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #12
Source File: FlutterCommand.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates the command line to run.
 * <p>
 * If a project is supplied, it will be used to determine the ANDROID_HOME variable for the subprocess.
 */
@NotNull
public GeneralCommandLine createGeneralCommandLine(@Nullable Project project) {
  final GeneralCommandLine line = new GeneralCommandLine();
  line.setCharset(CharsetToolkit.UTF8_CHARSET);
  line.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue());
  final String androidHome = IntelliJAndroidSdk.chooseAndroidHome(project, false);
  if (androidHome != null) {
    line.withEnvironment("ANDROID_HOME", androidHome);
  }
  line.setExePath(FileUtil.toSystemDependentName(sdk.getHomePath() + "/bin/" + FlutterSdkUtil.flutterScriptName()));
  if (workDir != null) {
    line.setWorkDirectory(workDir.getPath());
  }
  if (!isDoctorCommand()) {
    line.addParameter("--no-color");
  }
  line.addParameters(type.subCommand);
  line.addParameters(args);
  return line;
}
 
Example #13
Source File: JavaCommandBuilder.java    From intellij with Apache License 2.0 6 votes vote down vote up
GeneralCommandLine build() {
  checkArgument(javaBinary != null, "javaBinary was not set");
  checkArgument(mainClass != null, "mainClass was not set");
  GeneralCommandLine commandLine = new GeneralCommandLine(javaBinary.getPath());
  commandLine.addParameters("-cp", classpaths.stream().map(File::getPath).collect(joining(":")));
  commandLine.addParameters(jvmArgs);
  commandLine.addParameters(
      systemProperties.entrySet().stream()
          .map(e -> "-D" + e.getKey() + '=' + e.getValue())
          .collect(toList()));
  commandLine.addParameter(mainClass);
  commandLine.addParameters(programArgs);

  if (workingDirectory != null) {
    commandLine.setWorkDirectory(workingDirectory);
  }

  commandLine.withParentEnvironmentType(ParentEnvironmentType.NONE);
  environmentVariables.forEach(commandLine::withEnvironment);

  return commandLine;
}
 
Example #14
Source File: ScopedBlazeProcessHandler.java    From intellij with Apache License 2.0 6 votes vote down vote up
public ScopedBlazeProcessHandler(
    Project project,
    List<String> command,
    WorkspaceRoot workspaceRoot,
    ScopedProcessHandlerDelegate scopedProcessHandlerDelegate)
    throws ExecutionException {
  super(
      ProcessGroupUtil.newProcessGroupFor(
          new GeneralCommandLine(command)
              .withWorkDirectory(workspaceRoot.directory().getPath())
              .withRedirectErrorStream(true)));

  this.scopedProcessHandlerDelegate = scopedProcessHandlerDelegate;
  this.context = new BlazeContext();
  // The context is released in the ScopedProcessHandlerListener.
  this.context.hold();

  for (ProcessListener processListener :
      scopedProcessHandlerDelegate.createProcessListeners(context)) {
    addProcessListener(processListener);
  }
  addProcessListener(new ScopedProcessHandlerListener(project));
}
 
Example #15
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForFileWithoutTestScript() {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forFile("/workspace/foo/test/foo_test.dart", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #16
Source File: SimpleExportResult.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
public static SimpleExportResult getExportResult(@NotNull String pantsExecutable) {
  File pantsExecutableFile = new File(pantsExecutable);
  SimpleExportResult cache = simpleExportCache.get(pantsExecutableFile);
  if (cache != null) {
    return cache;
  }
  final GeneralCommandLine commandline = PantsUtil.defaultCommandLine(pantsExecutable);
  commandline.addParameters("--no-quiet", "export", PantsConstants.PANTS_CLI_OPTION_NO_COLORS);
  try (TempFile tempFile = TempFile.create("pants_export_run", ".out")) {
    commandline.addParameter(
      String.format("%s=%s", PantsConstants.PANTS_CLI_OPTION_EXPORT_OUTPUT_FILE,
                    tempFile.getFile().getPath()));
    final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandline, null);
    if (processOutput.checkSuccess(LOG)) {
      SimpleExportResult result = parse(FileUtil.loadFile(tempFile.getFile()));
      simpleExportCache.put(pantsExecutableFile, result);
      return result;
    }
  }
  catch (IOException | ExecutionException e) {
    // Fall-through to handle outside the block.
  }
  throw new PantsException("Failed:" + commandline.getCommandLineString());
}
 
Example #17
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineInRunMode() throws ExecutionException {
  final BazelFields fields = setupBazelFields();

  final FlutterDevice device = FlutterDevice.getTester();
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("flutter-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #18
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineWithBazelArgs() throws ExecutionException {
  final BazelFields fields = setupBazelFields(
    "bazel_target",
    "--define=bazel_args",
    null,
    false
  );

  final FlutterDevice device = FlutterDevice.getTester();
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("--define=bazel_args");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("flutter-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #19
Source File: OSSPantsJvmRunConfigurationIntegrationTest.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private GeneralCommandLine getFinalCommandline(
  ExternalSystemRunConfiguration esc,
  Class<? extends ExternalSystemTaskManager<PantsExecutionSettings>> taskManagerClass,
  OptionalInt debugPort
) throws InstantiationException, IllegalAccessException {
  PantsExecutionSettings settings = PantsExecutionSettings.createDefault();
  settings.withVmOptions(PantsUtil.parseCmdParameters(esc.getSettings().getVmOptions()));
  settings.withArguments(PantsUtil.parseCmdParameters(esc.getSettings().getScriptParameters()));
  debugPort.ifPresent(port -> settings.putUserData(BUILD_PROCESS_DEBUGGER_PORT_KEY, port));

  GeneralCommandLine commandLine = ((PantsTaskManager) taskManagerClass.newInstance()).constructCommandLine(
    esc.getSettings().getTaskNames(),
    esc.getSettings().getExternalProjectPath(),
    settings
  );
  assertNotNull(commandLine);
  return commandLine;
}
 
Example #20
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineInDebugMode() throws ExecutionException {
  final BazelFields fields = setupBazelFields();

  final FlutterDevice device = FlutterDevice.getTester();
  final GeneralCommandLine launchCommand =
    fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.DEBUG);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("--start-paused");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("flutter-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #21
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineWithAndroidEmulator() throws ExecutionException {
  final BazelFields fields = setupBazelFields();

  final FlutterDevice device = new FlutterDevice("android-tester", "android device", "android", true);
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), device, RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/bazel-run.sh");
  expectedCommandLine.add("--define");
  expectedCommandLine.add("flutter_build_mode=debug");
  expectedCommandLine.add("bazel_target");
  expectedCommandLine.add("--");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("-d");
  expectedCommandLine.add("android-tester");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #22
Source File: BuckCommandHandler.java    From buck with Apache License 2.0 6 votes vote down vote up
/**
 * @param project a project
 * @param command a command to execute (if empty string, the parameter is ignored)
 * @param doStartNotify true if the handler should call OSHandler#startNotify
 */
public BuckCommandHandler(Project project, BuckCommand command, boolean doStartNotify) {
  this.doStartNotify = doStartNotify;

  String buckExecutable =
      BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable();

  this.project = project;
  this.buckModule = project.getComponent(BuckModule.class);
  this.command = command;
  commandLine = new GeneralCommandLine();
  commandLine.setExePath(buckExecutable);
  commandLine.withWorkDirectory(calcWorkingDirFor(project));
  commandLine.withEnvironment(EnvironmentUtil.getEnvironmentMap());
  commandLine.addParameter(command.name());
  for (String parameter : command.getParameters()) {
    commandLine.addParameter(parameter);
  }
}
 
Example #23
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForTestNameAndBazelTargetWithoutTestScript() throws ExecutionException {
  final BazelTestFields fields = new FakeBazelTestFields(
    new BazelTestFields(null, "/workspace/foo/test/foo_test.dart", "//foo:test", "--ignored-args"),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );

  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #24
Source File: BuckCommandHandler.java    From Buck-IntelliJ-Plugin with Apache License 2.0 6 votes vote down vote up
/**
 * @param project   a project
 * @param directory a process directory
 * @param command   a command to execute (if empty string, the parameter is ignored)
 */
public BuckCommandHandler(
    Project project,
    File directory,
    BuckCommand command) {

  String buckExecutable = BuckSettingsProvider.getInstance().getState().buckExecutable;

  mProject = project;
  mCommand = command;
  mCommandLine = new GeneralCommandLine();
  mCommandLine.setExePath(buckExecutable);
  mWorkingDirectory = directory;
  mCommandLine.withWorkDirectory(mWorkingDirectory);
  mCommandLine.addParameter(command.name());
}
 
Example #25
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineForTestNameWithNoMachineFlag() throws ExecutionException {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forTestName("first test", "/workspace/foo/test/foo_test.dart", "--no-machine")
  );
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/flutter-test.sh");
  expectedCommandLine.add("--no-machine");
  expectedCommandLine.add("--no-color");
  expectedCommandLine.add("--name");
  expectedCommandLine.add("first test");
  expectedCommandLine.add("foo/test/foo_test.dart");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #26
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void producesCorrectCommandLineForBazelTargetWithoutTestScript() throws ExecutionException {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forTarget("//foo:test", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/launch.sh");
  expectedCommandLine.add("--no-color");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("//foo:test");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #27
Source File: FlutterConsoleFilter.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void navigate(Project project) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening ", myPath);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException e) {
    FlutterMessages.showError(
      "Error Opening External File",
      "Exception: " + e.getMessage());
  }
}
 
Example #28
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForTestNameWithoutTestScript() {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forTestName("first test", "/workspace/foo/test/foo_test.dart", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #29
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void runsInFileModeWhenBothFileAndBazelTargetAreProvided() throws ExecutionException {
  final BazelTestFields fields = new FakeBazelTestFields(
    new BazelTestFields(null, "/workspace/foo/test/foo_test.dart", "//foo:test", "--arg1 --arg2 3")
  );
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/flutter-test.sh");
  expectedCommandLine.add("--arg1");
  expectedCommandLine.add("--arg2");
  expectedCommandLine.add("3");
  expectedCommandLine.add("--no-color");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("foo/test/foo_test.dart");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #30
Source File: ShowFilePathAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void schedule(GeneralCommandLine cmd) {
  PooledThreadExecutor.INSTANCE.submit(() -> {
    try {
      LOG.debug(cmd.toString());
      ExecUtil.execAndGetOutput(cmd).checkSuccess(LOG);
    }
    catch (Exception e) {
      LOG.warn(e);
    }
  });
}