Search in sources :

Example 1 with GaugeNotFoundException

use of com.thoughtworks.gauge.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.

the class GaugeModuleComponent method initializeGaugeProcess.

private static Process initializeGaugeProcess(int apiPort, Module module) {
    try {
        GaugeSettingsModel settings = getGaugeSettings();
        String port = String.valueOf(apiPort);
        ProcessBuilder gauge = new ProcessBuilder(settings.getGaugePath(), Constants.DAEMON, port);
        GaugeUtil.setGaugeEnvironmentsTo(gauge, settings);
        String cp = classpathForModule(module);
        LOG.info(String.format("Setting `%s` to `%s`", Constants.GAUGE_CUSTOM_CLASSPATH, cp));
        gauge.environment().put(Constants.GAUGE_CUSTOM_CLASSPATH, cp);
        File dir = moduleDir(module);
        LOG.info(String.format("Using `%s` as api port to connect to gauge API for project %s", port, dir));
        gauge.directory(dir);
        Process process = gauge.start();
        new GaugeExceptionHandler(process, module.getProject()).start();
        return process;
    } catch (IOException | GaugeNotFoundException e) {
        LOG.error("An error occurred while starting gauge api. \n" + e);
    }
    return null;
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) GaugeExceptionHandler(com.thoughtworks.gauge.core.GaugeExceptionHandler) IOException(java.io.IOException) File(java.io.File) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel)

Example 2 with GaugeNotFoundException

use of com.thoughtworks.gauge.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.

the class GaugeCommandLine method getInstance.

public static GeneralCommandLine getInstance(Module module, Project project) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    try {
        GaugeSettingsModel settings = GaugeUtil.getGaugeSettings();
        commandLine.setExePath(settings.getGaugePath());
        Map<String, String> environment = commandLine.getEnvironment();
        environment.put(Constants.GAUGE_HOME, settings.getHomePath());
    } catch (GaugeNotFoundException e) {
        commandLine.setExePath(Constants.GAUGE);
    } finally {
        commandLine.setWorkDirectory(project.getBasePath());
        if (module != null)
            commandLine.setWorkDirectory(GaugeUtil.moduleDir(module));
        return commandLine;
    }
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel)

Example 3 with GaugeNotFoundException

use of com.thoughtworks.gauge.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.

the class GaugeInspectionHelper method getErrors.

@NotNull
static List<GaugeError> getErrors(File directory) {
    try {
        GaugeSettingsModel settings = getGaugeSettings();
        ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.VALIDATE);
        GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
        processBuilder.directory(directory);
        Process process = processBuilder.start();
        process.waitFor();
        String[] errors = GaugeUtil.getOutput(process.getInputStream(), "\n").split("\n");
        return Arrays.stream(errors).map(GaugeError::getInstance).filter(Objects::nonNull).collect(Collectors.toList());
    } catch (IOException | InterruptedException | GaugeNotFoundException e) {
        e.printStackTrace();
    }
    return new ArrayList<>();
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with GaugeNotFoundException

use of com.thoughtworks.gauge.exception.GaugeNotFoundException in project Intellij-Plugin by getgauge.

the class GaugeUtil method getSettingsFromPATH.

private static GaugeSettingsModel getSettingsFromPATH(GaugeSettingsModel model) throws GaugeNotFoundException {
    String path = EnvironmentUtil.getValue("PATH");
    LOG.info("PATH => " + path);
    if (!StringUtils.isEmpty(path)) {
        for (String entry : path.split(File.pathSeparator)) {
            File file = new File(entry, gaugeExecutable());
            if (isValidGaugeExec(file)) {
                LOG.info("executable path from `PATH`: " + file.getAbsolutePath());
                return new GaugeSettingsModel(file.getAbsolutePath(), model.getHomePath(), model.useIntelliJTestRunner());
            }
        }
    }
    String msg = "Could not find executable in `PATH`. Please make sure Gauge is installed." + "\nIf Gauge is installed then set the Gauge executable path in settings -> tools -> gauge.";
    throw new GaugeNotFoundException(msg);
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File) SpecFile(com.thoughtworks.gauge.language.SpecFile) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel)

Aggregations

GaugeNotFoundException (com.thoughtworks.gauge.exception.GaugeNotFoundException)4 GaugeSettingsModel (com.thoughtworks.gauge.settings.GaugeSettingsModel)4 File (java.io.File)2 IOException (java.io.IOException)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 GaugeExceptionHandler (com.thoughtworks.gauge.core.GaugeExceptionHandler)1 SpecFile (com.thoughtworks.gauge.language.SpecFile)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1