Examples of GeneralCommandLine


Examples of com.intellij.execution.configurations.GeneralCommandLine

    return processHandler;
  }

  @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.setWorkDirectory(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;
  }
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        if (data == null)
            return null;

        try {
            GeneralCommandLine command = new GeneralCommandLine();
            command.setExePath(goCommand);
            command.addParameter("version");
            command.withWorkDirectory(path);
            command.getEnvironment().put("GOROOT", path);

            ProcessOutput output = new CapturingProcessHandler(
                    command.createProcess(),
                    Charset.defaultCharset(),
                    command.getCommandLineString()).runProcess();

            if (output.getExitCode() != 0) {
                LOG.error("Go compiler exited with invalid exit code: " +
                        output.getExitCode());
                return null;
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        if (data == null)
            return data;

        try {
            GeneralCommandLine command = new GeneralCommandLine();
            command.setExePath(goCommand);
            command.addParameter("env");
            command.withWorkDirectory(path);
            command.getEnvironment().put("GOROOT", path);

            ProcessOutput output = new CapturingProcessHandler(
                    command.createProcess(),
                    Charset.defaultCharset(),
                    command.getCommandLineString()).runProcess();

            if (output.getExitCode() != 0) {
                LOG.error(
                        format(
                                "%s env command exited with invalid exit code: %d",
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        if (isHostOsWindows()) {
            execName += ".exe";
        }
        String homePath = sdkData.GO_HOME_PATH + "/bin";

        GeneralCommandLine command = new GeneralCommandLine();
        if (checkFileExists(execName)) {
            execName = sdkData.GO_HOME_PATH + "/../goapp";
            if (isHostOsWindows()) {
                execName += ".bat";
            }
            homePath = sdkData.GO_HOME_PATH + "/..";

            if (!checkFileExists(execName)) {
                return null;
            }
        }

        command.setExePath(execName);
        command.withWorkDirectory(homePath);
        command.addParameter("env");

        sdkData.TARGET_ARCH = GoTargetArch._amd64;
        sdkData.TARGET_OS = GoTargetOs.Linux;

        try {
            ProcessOutput output = new CapturingProcessHandler(
                    command.createProcess(),
                    Charset.defaultCharset(),
                    command.getCommandLineString()).runProcess();

            if (output.getExitCode() != 0) {
                LOG.error("Go command exited with invalid exit code: " +
                        output.getExitCode());
                return null;
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        } else if (GoUtil.testGoHomeFolder("/usr/local/go") &&
                new File("/usr/local/go/bin/go").canExecute()) {
            command = "/usr/local/go/bin/go";
        }

        GeneralCommandLine goCommandLine = new GeneralCommandLine();

        goCommandLine.setExePath(command);
        goCommandLine.addParameter("env");

        LOG.info("command: " + command);

        try {
            ProcessOutput output = new CapturingProcessHandler(
                    goCommandLine.createProcess(),
                    Charset.defaultCharset(),
                    goCommandLine.getCommandLineString()).runProcess();

            if (output.getExitCode() == 0) {
                String outputString = output.getStdout();

                LOG.info("Output:\n" + outputString);
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        return editingSupport.get(goType);
    }

    public static Boolean isKnownGdb(String path) {
        try {
            GeneralCommandLine command = new GeneralCommandLine();
            command.setExePath(path);
            command.addParameter("--version");

            ProcessOutput output = new CapturingProcessHandler(
                    command.createProcess(),
                    Charset.defaultCharset(),
                    command.getCommandLineString()).runProcess();

            if (output.getExitCode() != 0) {
                LOG.error("gdb exited with invalid exit code: " + output.getExitCode());
                return false;
            }
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        }
    }

    public static Boolean isValidGdbPath(String path) {
        try {
            GeneralCommandLine command = new GeneralCommandLine();
            command.setExePath(path);
            command.addParameter("--version");

            ProcessOutput output = new CapturingProcessHandler(
                    command.createProcess(),
                    Charset.defaultCharset(),
                    command.getCommandLineString()).runProcess();

            if (output.getExitCode() != 0) {
                LOG.error("gdb exited with invalid exit code: " + output.getExitCode());
                return false;
            }
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

        GoToolWindow toolWindow = GoToolWindow.getInstance(m_project);
        toolWindow.setTitle(TITLE);

        if (!m_configuration.goBuildBeforeRun && !m_configuration.runPackage) {
            // Just run
            GeneralCommandLine commandLine = new GeneralCommandLine();

            commandLine.setExePath(goExecName);
            commandLine.addParameter("run");
            if (m_configuration.runBuilderArguments != null && m_configuration.runBuilderArguments.trim().length() > 0) {
                commandLine.getParametersList().addParametersString(m_configuration.runBuilderArguments);
            }

            commandLine.addParameter(m_configuration.scriptName);
            if (m_configuration.scriptArguments != null && m_configuration.scriptArguments.trim().length() > 0) {
                commandLine.getParametersList().addParametersString(m_configuration.scriptArguments);
            }

            commandLine.getEnvironment().putAll(sysEnv);
            commandLine.withWorkDirectory(m_configuration.workingDir);

            return GoApplicationProcessHandler.runCommandLine(commandLine);
        }

        // Build and run
        String execName;
        if (m_configuration.runExecutableName != null && m_configuration.runExecutableName.trim().length() > 0) {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.runExecutableName);
        }
        else {
            execName = m_configuration.goOutputDir.concat("/").concat(m_configuration.getName());
        }

        if (execName.endsWith(".go")) {
            execName = execName.substring(0, execName.length() - 3);
        }

        if (GoSdkUtil.isHostOsWindows()) {
            if (!execName.endsWith(".exe")) {
                execName = execName.concat(".exe");
            }
        }

        (new File(execName)).delete();

        try {
            String[] goEnv = GoSdkUtil.convertEnvMapToArray(sysEnv);

            String scriptOrPackage;
            if (m_configuration.runPackage) {
                scriptOrPackage = new java.io.File(m_configuration.getProject().getBaseDir().getPath().concat("/src")).toURI().relativize(new java.io.File(m_configuration.packageDir).toURI()).getPath();
            }
            else {
                scriptOrPackage = m_configuration.scriptName;
            }
            String[] command = GoSdkUtil.computeGoBuildCommand(goExecName, m_configuration.runBuilderArguments, execName, scriptOrPackage);

            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec(command, goEnv, new File(projectDir));
            OSProcessHandler handler = new OSProcessHandler(proc, null);
            toolWindow.attachConsoleViewToProcess(handler);
            toolWindow.printNormalMessage(String.format("%s%n", StringUtil.join(command, " ")));
            toolWindow.showAndCreate(m_project);
            handler.startNotify();

            if (proc.waitFor() == 0) {
                VirtualFileManager.getInstance().syncRefresh();
                toolWindow.printNormalMessage(String.format("%nFinished building project %s%n", execName));
            } else {
                toolWindow.printErrorMessage(String.format("%nCould't build project %s%n", execName));
                throw new CantRunException(String.format("Error while processing %s build command.", goExecName));
            }
        } catch (Exception e) {
            throw new CantRunException(String.format("Error while processing %s build command.", goExecName));
        }

        // Now run the build
        GeneralCommandLine commandLine = new GeneralCommandLine();

        commandLine.setExePath(execName);
        commandLine.withWorkDirectory(m_configuration.workingDir);
        if (m_configuration.scriptArguments != null && m_configuration.scriptArguments.trim().length() > 0) {
            commandLine.getParametersList().addParametersString(m_configuration.scriptArguments);
        }

        return GoApplicationProcessHandler.runCommandLine(commandLine);
    }
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

                throw new CantRunException(String.format("Error while processing %s vet command.", goExecName));
            }
        }

        // Install dependencies
        GeneralCommandLine testInstallDependencies = new GeneralCommandLine();
        testInstallDependencies.setExePath(goExecName);
        testInstallDependencies.addParameter("test");
        testInstallDependencies.addParameter("-i");

        if (testConfiguration.testArgs != null && testConfiguration.testArgs.trim().length() > 0) {
            testInstallDependencies.getParametersList().addParametersString(testConfiguration.testArgs);
        }

        if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.Package)) {
            testInstallDependencies.addParameter(testConfiguration.packageName);
        } else if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.File)) {
            testInstallDependencies.addParameter(testConfiguration.testFile);
        } else if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.CWD)) {
            testInstallDependencies.addParameter("./...");
        }

        testInstallDependencies.getEnvironment().putAll(sysEnv);
        testInstallDependencies.withWorkDirectory(workingDir);
        try {
            if (testInstallDependencies.createProcess().waitFor() == 0) {
                VirtualFileManager.getInstance().syncRefresh();
            }
        } catch (InterruptedException ignored) {
        }

        // Run the test
        GeneralCommandLine commandLine = new GeneralCommandLine();
        commandLine.setExePath(goExecName);
        commandLine.addParameter("test");
        commandLine.addParameter("-v");
        if (testConfiguration.useShortRun)
            commandLine.addParameter("-short");

        switch (testConfiguration.executeWhat) {
            case Test:
                if (testConfiguration.filter != null && !testConfiguration.filter.isEmpty())
                    commandLine.addParameter("-run=" + testConfiguration.filter.trim());
                break;
            case Benchmark:
                String benchmarkName = ".*";

                if (testConfiguration.filter != null && !testConfiguration.filter.isEmpty())
                    benchmarkName = testConfiguration.filter.trim();
                if (!testConfiguration.testBeforeBenchmark) {
                    commandLine.addParameter("-run=NONE");
                }
                commandLine.addParameter("-bench=" + benchmarkName);
                break;
        }

        if (testConfiguration.testRunnerArgs != null && testConfiguration.testRunnerArgs.trim().length() > 0) {
            commandLine.getParametersList().addParametersString(testConfiguration.testRunnerArgs);
        }

        if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.Package)) {
            commandLine.addParameter(testConfiguration.packageName);
        } else if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.File)) {
            commandLine.addParameter(testConfiguration.testFile);
        } else if (testConfiguration.testTargetType.equals(GoTestConfiguration.TestTargetType.CWD)) {
            commandLine.addParameter("./...");
        }

        commandLine.getEnvironment().putAll(sysEnv);
        commandLine.withWorkDirectory(workingDir);

        if (testConfiguration.testArgs != null && testConfiguration.testArgs.trim().length() > 0) {
            commandLine.getParametersList().addParametersString(testConfiguration.testArgs);
        }

        return GoApplicationProcessHandler.runCommandLine(commandLine);
    }
View Full Code Here

Examples of com.intellij.execution.configurations.GeneralCommandLine

    }

    @NotNull
    @Override
    protected OSProcessHandler startProcess() throws ExecutionException {
        GeneralCommandLine commandLine = generateCommandLine();
        OSProcessHandler osProcessHandler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
        ProcessTerminatedListener.attach(osProcessHandler);
        return osProcessHandler;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.