Search in sources :

Example 1 with KarmaConfig

use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.

the class KarmaTestProxyFilterProvider method getFilter.

@Nullable
@Override
public Filter getFilter(@NotNull String nodeType, @NotNull String nodeName, @Nullable String nodeArguments) {
    KarmaConfig config = myKarmaServer.getKarmaConfig();
    String baseDir = config != null ? config.getBasePath() : null;
    if ("browser".equals(nodeType)) {
        AbstractFileHyperlinkFilter browserFilter = BrowserStacktraceFilters.createFilter(nodeName, myProject, baseDir);
        if (browserFilter != null) {
            return new KarmaSourceMapStacktraceFilter(myProject, baseDir, browserFilter);
        }
    }
    if ("browserError".equals(nodeType)) {
        return getBrowserErrorFilter();
    }
    return null;
}
Also used : AbstractFileHyperlinkFilter(com.intellij.execution.filters.AbstractFileHyperlinkFilter) KarmaConfig(com.intellij.javascript.karma.KarmaConfig) KarmaSourceMapStacktraceFilter(com.intellij.javascript.karma.filter.KarmaSourceMapStacktraceFilter) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with KarmaConfig

use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.

the class KarmaServerState method canSetBrowsersReady.

private boolean canSetBrowsersReady() {
    List<String> expectedBrowsers = myOverriddenBrowsers;
    if (expectedBrowsers == null) {
        KarmaConfig config = myConfig;
        if (config == null) {
            return true;
        }
        expectedBrowsers = config.getBrowsers();
    }
    Set<String> expectedBrowserSet = ContainerUtil.newHashSet(expectedBrowsers);
    expectedBrowserSet.removeAll(myFailedToStartBrowsers);
    int autoCapturedBrowserCount = getAutoCapturedBrowserCount();
    return autoCapturedBrowserCount > 0 && expectedBrowserSet.size() <= autoCapturedBrowserCount;
}
Also used : KarmaConfig(com.intellij.javascript.karma.KarmaConfig)

Example 3 with KarmaConfig

use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.

the class KarmaDebugProgramRunner method getDebuggableFileFinder.

private static DebuggableFileFinder getDebuggableFileFinder(@NotNull KarmaServer karmaServer) {
    BiMap<String, VirtualFile> mappings = HashBiMap.create();
    KarmaConfig karmaConfig = karmaServer.getKarmaConfig();
    if (karmaConfig != null) {
        VirtualFile basePath = LocalFileSystem.getInstance().findFileByPath(karmaConfig.getBasePath());
        if (basePath != null && basePath.isValid()) {
            if (karmaConfig.isWebpack()) {
                mappings.put("webpack:///" + basePath.getPath(), basePath);
                VirtualFile nodeModulesDir = basePath.findChild(NodeModuleUtil.NODE_MODULES);
                if (nodeModulesDir != null && nodeModulesDir.isValid() && nodeModulesDir.isDirectory()) {
                    mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base/" + NodeModuleUtil.NODE_MODULES), nodeModulesDir);
                }
            } else {
                mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base"), basePath);
            }
        }
    }
    if (SystemInfo.isWindows) {
        VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
        for (VirtualFile root : roots) {
            String key = karmaServer.formatUrlWithoutUrlRoot("/absolute" + root.getName());
            if (mappings.containsKey(key)) {
                LOG.warn("Duplicate mapping for Karma debug: " + key);
            } else {
                mappings.put(key, root);
            }
        }
    } else {
        VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
        if (roots.length == 1) {
            mappings.put(karmaServer.formatUrlWithoutUrlRoot("/absolute"), roots[0]);
        }
    }
    return new RemoteDebuggingFileFinder(mappings, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RemoteDebuggingFileFinder(com.intellij.javascript.debugger.RemoteDebuggingFileFinder) KarmaConfig(com.intellij.javascript.karma.KarmaConfig)

Example 4 with KarmaConfig

use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.

the class KarmaExecutionSession method createCommandLine.

@NotNull
private GeneralCommandLine createCommandLine(@NotNull NodeJsLocalInterpreter interpreter, int serverPort, @Nullable KarmaConfig config, @NotNull File clientAppFile) throws ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    File configFile = new File(myRunSettings.getConfigPath());
    // looks like it should work with any working directory
    commandLine.setWorkDirectory(configFile.getParentFile());
    commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
    commandLine.setExePath(interpreter.getInterpreterSystemDependentPath());
    //NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 5858, false, interpreter, true);
    commandLine.addParameter(clientAppFile.getAbsolutePath());
    commandLine.addParameter("--karmaPackageDir=" + myKarmaServer.getServerSettings().getKarmaPackage().getSystemDependentPath());
    commandLine.addParameter("--serverPort=" + serverPort);
    if (config != null) {
        commandLine.addParameter("--urlRoot=" + config.getUrlRoot());
    }
    if (isDebug()) {
        commandLine.addParameter("--debug=true");
    }
    if (myRunSettings.getScopeKind() == KarmaScopeKind.TEST_FILE) {
        List<String> topNames = findTopLevelSuiteNames(myProject, myRunSettings.getTestFileSystemIndependentPath());
        if (topNames.size() > 1) {
            throw new ExecutionException("Cannot run test file with several top level suites");
        }
        topNames = ContainerUtil.map(topNames, s -> s + " ");
        commandLine.addParameter("--testName=" + StringUtil.join(topNames, "|"));
    } else if (myRunSettings.getScopeKind() == KarmaScopeKind.SUITE || myRunSettings.getScopeKind() == KarmaScopeKind.TEST) {
        commandLine.addParameter("--testName=" + StringUtil.join(myRunSettings.getTestNames(), " "));
    }
    return commandLine;
}
Also used : TestProxyFilterProvider(com.intellij.execution.testframework.sm.runner.TestProxyFilterProvider) CharsetToolkit(com.intellij.openapi.vfs.CharsetToolkit) ExecutionException(com.intellij.execution.ExecutionException) SMTestRunnerConnectionUtil(com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) com.intellij.execution.process(com.intellij.execution.process) QUnitFileStructureBuilder(com.intellij.javascript.testFramework.qunit.QUnitFileStructureBuilder) ContainerUtil(com.intellij.util.containers.ContainerUtil) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) PsiManager(com.intellij.psi.PsiManager) QUnitFileStructure(com.intellij.javascript.testFramework.qunit.QUnitFileStructure) KarmaConfig(com.intellij.javascript.karma.KarmaConfig) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) Disposer(com.intellij.openapi.util.Disposer) SMTRunnerConsoleProperties(com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) JasmineFileStructureBuilder(com.intellij.javascript.testFramework.jasmine.JasmineFileStructureBuilder) Logger(com.intellij.openapi.diagnostic.Logger) JSFile(com.intellij.lang.javascript.psi.JSFile) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) KarmaTestProxyFilterProvider(com.intellij.javascript.karma.tree.KarmaTestProxyFilterProvider) StringUtil(com.intellij.openapi.util.text.StringUtil) JasmineFileStructure(com.intellij.javascript.testFramework.jasmine.JasmineFileStructure) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) SMTestLocator(com.intellij.execution.testframework.sm.runner.SMTestLocator) LocalFileFinder(org.jetbrains.io.LocalFileFinder) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties) KarmaServerTerminatedListener(com.intellij.javascript.karma.server.KarmaServerTerminatedListener) ObjectUtils(com.intellij.util.ObjectUtils) NotNull(org.jetbrains.annotations.NotNull) KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) JSFile(com.intellij.lang.javascript.psi.JSFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with KarmaConfig

use of com.intellij.javascript.karma.KarmaConfig in project intellij-plugins by JetBrains.

the class KarmaCoverageRunner method loadCoverageData.

@Override
public ProjectData loadCoverageData(@NotNull File sessionDataFile, @Nullable CoverageSuite baseCoverageSuite) {
    KarmaConfig karmaConfig = null;
    if (myKarmaServer != null) {
        karmaConfig = myKarmaServer.getKarmaConfig();
    }
    String basePath = null;
    if (karmaConfig != null) {
        basePath = karmaConfig.getBasePath();
    }
    if (basePath != null) {
        File basePathDir = new File(basePath);
        if (basePathDir.isAbsolute() && basePathDir.isDirectory()) {
            try {
                return readProjectData(sessionDataFile, basePathDir);
            } catch (Exception e) {
                LOG.warn("Can't read coverage data", e);
            }
        }
    }
    return null;
}
Also used : KarmaConfig(com.intellij.javascript.karma.KarmaConfig) File(java.io.File) IOException(java.io.IOException)

Aggregations

KarmaConfig (com.intellij.javascript.karma.KarmaConfig)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 IOException (java.io.IOException)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 AbstractFileHyperlinkFilter (com.intellij.execution.filters.AbstractFileHyperlinkFilter)1 com.intellij.execution.process (com.intellij.execution.process)1 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)1 SMTestRunnerConnectionUtil (com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil)1 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)1 SMTestLocator (com.intellij.execution.testframework.sm.runner.SMTestLocator)1 TestProxyFilterProvider (com.intellij.execution.testframework.sm.runner.TestProxyFilterProvider)1 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)1 RemoteDebuggingFileFinder (com.intellij.javascript.debugger.RemoteDebuggingFileFinder)1 KarmaSourceMapStacktraceFilter (com.intellij.javascript.karma.filter.KarmaSourceMapStacktraceFilter)1 KarmaScopeKind (com.intellij.javascript.karma.scope.KarmaScopeKind)1