Search in sources :

Example 1 with BasePaths

use of com.google.jstestdriver.model.BasePaths in project intellij-plugins by JetBrains.

the class JstdTestFilePathIndex method getIndexer.

@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return new DataIndexer<String, Void, FileContent>() {

        @Override
        @NotNull
        public Map<String, Void> map(@NotNull final FileContent inputData) {
            VirtualFile file = inputData.getFile();
            if (file.isValid()) {
                VirtualFile dir = file.getParent();
                if (dir.isValid()) {
                    BasePaths basePaths = new BasePaths(new File(dir.getPath()));
                    Reader reader = new InputStreamReader(new ByteArrayInputStream(inputData.getContent()), Charset.defaultCharset());
                    try {
                        return doIndexConfigFile(reader, basePaths);
                    } catch (Exception ignored) {
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException ignored) {
                        }
                    }
                }
            }
            return Collections.emptyMap();
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) BasePaths(com.google.jstestdriver.model.BasePaths) NotNull(org.jetbrains.annotations.NotNull) VirtualFile(com.intellij.openapi.vfs.VirtualFile) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with BasePaths

use of com.google.jstestdriver.model.BasePaths in project intellij-plugins by JetBrains.

the class JstdConfigParsingUtils method parseConfiguration.

public static ParsedConfiguration parseConfiguration(@NotNull File configFile) {
    BasePaths basePaths = new BasePaths(configFile.getParentFile());
    ConfigurationSource configurationSource = new UserConfigurationSource(configFile);
    Configuration configuration = configurationSource.parse(basePaths, new YamlParser());
    return (ParsedConfiguration) configuration;
}
Also used : BasePaths(com.google.jstestdriver.model.BasePaths)

Example 3 with BasePaths

use of com.google.jstestdriver.model.BasePaths in project intellij-plugins by JetBrains.

the class JstdServerMain method main.

public static void main(String[] args) {
    shutdownIfOrphan();
    try {
        // pre-parse parsing... These are the flags
        // that must be dealt with before we parse the flags.
        CmdLineFlags cmdLineFlags = new CmdLineFlagsFactory().create(args);
        List<Plugin> cmdLinePlugins = cmdLineFlags.getPlugins();
        // configure logging before we start seriously processing.
        LogManager.getLogManager().readConfiguration(cmdLineFlags.getRunnerMode().getLogConfig());
        final PluginLoader pluginLoader = new PluginLoader();
        // load all the command line plugins.
        final List<Module> pluginModules = pluginLoader.load(cmdLinePlugins);
        logger.log(Level.INFO, "loaded plugins {0}", pluginModules);
        JsTestDriverBuilder builder = new JsTestDriverBuilder();
        BasePaths basePath = cmdLineFlags.getBasePath();
        builder.addBasePaths(basePath);
        builder.setDefaultConfiguration(new DefaultConfiguration(basePath));
        builder.setConfigurationSource(cmdLineFlags.getConfigurationSource());
        builder.addPluginModules(pluginModules);
        builder.withPluginInitializer(TestResultPrintingModule.TestResultPrintingInitializer.class);
        builder.setRunnerMode(cmdLineFlags.getRunnerMode());
        builder.setFlags(cmdLineFlags.getUnusedFlagsAsArgs());
        builder.addServerListener(new JstdIntellijServerListener());
        JsTestDriver jstd = builder.build();
        jstd.runConfiguration();
        logger.info("Finished action run.");
    } catch (InvalidFlagException e) {
        e.printErrorMessages(System.out);
        CmdLineFlags.printUsage(System.out);
        System.exit(1);
    } catch (UnreadableFilesException e) {
        System.out.println("Configuration Error: \n" + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    } catch (ConfigurationException e) {
        System.out.println("Configuration Error: \n" + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    } catch (RetryException e) {
        System.out.println("Tests failed due to unexpected environment issue: " + e.getCause().getMessage());
        System.exit(1);
    } catch (FailureException e) {
        System.out.println("Tests failed: " + e.getMessage());
        System.exit(1);
    } catch (BrowserPanicException e) {
        System.out.println("Test run failed due to unresponsive browser: " + e);
        System.exit(1);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Unexpected Runner Condition: " + e.getMessage() + "\n Use --runnerMode DEBUG for more information.");
        System.exit(1);
    }
}
Also used : BrowserPanicException(com.google.jstestdriver.browser.BrowserPanicException) JsTestDriver(com.google.jstestdriver.JsTestDriver) BasePaths(com.google.jstestdriver.model.BasePaths) TestResultPrintingModule(com.google.jstestdriver.guice.TestResultPrintingModule) RetryException(com.google.jstestdriver.util.RetryException) JsTestDriverBuilder(com.google.jstestdriver.embedded.JsTestDriverBuilder) FailureException(com.google.jstestdriver.FailureException) BrowserPanicException(com.google.jstestdriver.browser.BrowserPanicException) IOException(java.io.IOException) FailureException(com.google.jstestdriver.FailureException) RetryException(com.google.jstestdriver.util.RetryException) Module(com.google.inject.Module) TestResultPrintingModule(com.google.jstestdriver.guice.TestResultPrintingModule) PluginLoader(com.google.jstestdriver.PluginLoader) Plugin(com.google.jstestdriver.Plugin)

Example 4 with BasePaths

use of com.google.jstestdriver.model.BasePaths in project intellij-plugins by JetBrains.

the class JstdDebuggingFileFinderProvider method resolveConfiguration.

@NotNull
private ResolvedConfiguration resolveConfiguration() throws ExecutionException {
    VirtualFile configVirtualFile = VfsUtil.findFileByIoFile(myConfigFile, false);
    if (configVirtualFile == null) {
        throw new ExecutionException("Cannot find JsTestDriver configuration file " + myConfigFile.getAbsolutePath());
    }
    BasePaths dirBasePaths = new BasePaths(myConfigFile.getParentFile());
    final byte[] content;
    try {
        content = configVirtualFile.contentsToByteArray();
    } catch (IOException e) {
        throw new ExecutionException("Cannot read JsTestDriver configuration file " + configVirtualFile.getPath());
    }
    Reader reader = new InputStreamReader(new ByteArrayInputStream(content), Charset.defaultCharset());
    try {
        YamlParser yamlParser = new YamlParser();
        ParsedConfiguration parsedConfiguration = (ParsedConfiguration) yamlParser.parse(reader, dirBasePaths);
        JstdConfigParsingUtils.wipeCoveragePlugin(parsedConfiguration);
        return JstdConfigParsingUtils.resolveConfiguration(parsedConfiguration);
    } catch (Exception e) {
        String message = "Malformed JsTestDriver configuration file " + configVirtualFile.getPath();
        LOG.warn(message, e);
        throw new ExecutionException(message);
    } finally {
        try {
            reader.close();
        } catch (IOException ignored) {
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) YamlParser(com.google.jstestdriver.config.YamlParser) ParsedConfiguration(com.google.jstestdriver.config.ParsedConfiguration) ExecutionException(com.intellij.execution.ExecutionException) BasePaths(com.google.jstestdriver.model.BasePaths) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

BasePaths (com.google.jstestdriver.model.BasePaths)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 Module (com.google.inject.Module)1 FailureException (com.google.jstestdriver.FailureException)1 JsTestDriver (com.google.jstestdriver.JsTestDriver)1 Plugin (com.google.jstestdriver.Plugin)1 PluginLoader (com.google.jstestdriver.PluginLoader)1 BrowserPanicException (com.google.jstestdriver.browser.BrowserPanicException)1 ParsedConfiguration (com.google.jstestdriver.config.ParsedConfiguration)1 YamlParser (com.google.jstestdriver.config.YamlParser)1 JsTestDriverBuilder (com.google.jstestdriver.embedded.JsTestDriverBuilder)1 TestResultPrintingModule (com.google.jstestdriver.guice.TestResultPrintingModule)1 RetryException (com.google.jstestdriver.util.RetryException)1 ExecutionException (com.intellij.execution.ExecutionException)1 IOException (java.io.IOException)1