Search in sources :

Example 1 with NodeJsLocalInterpreter

use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.

the class KarmaRunProfileState method getServerOrStart.

@Nullable
public KarmaServer getServerOrStart(@NotNull final Executor executor) throws ExecutionException {
    NodeJsInterpreter interpreter = myRunSettings.getInterpreterRef().resolve(myProject);
    NodeJsLocalInterpreter localInterpreter = NodeJsLocalInterpreter.castAndValidate(interpreter);
    KarmaServerSettings serverSettings = new KarmaServerSettings.Builder().setNodeInterpreter(localInterpreter).setKarmaPackage(myKarmaPackage).setRunSettings(myRunSettings).setWithCoverage(myExecutionType == KarmaExecutionType.COVERAGE).setDebug(myExecutionType == KarmaExecutionType.DEBUG).build();
    KarmaServerRegistry registry = KarmaServerRegistry.getInstance(myProject);
    KarmaServer server = registry.getServer(serverSettings);
    if (server != null && server.getRestarter().isRestartRequired()) {
        server.shutdownAsync();
        server = null;
    }
    if (server == null) {
        registry.startServer(serverSettings, new CatchingConsumer<KarmaServer, Exception>() {

            @Override
            public void consume(KarmaServer server) {
                RunnerAndConfigurationSettings configuration = myEnvironment.getRunnerAndConfigurationSettings();
                if (configuration != null) {
                    ProgramRunnerUtil.executeConfiguration(myProject, configuration, executor);
                }
            }

            @Override
            public void consume(final Exception e) {
                LOG.error(e);
                showServerStartupError(e);
            }
        });
    }
    return server;
}
Also used : NodeJsInterpreter(com.intellij.javascript.nodejs.interpreter.NodeJsInterpreter) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) KarmaServerRegistry(com.intellij.javascript.karma.server.KarmaServerRegistry) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with NodeJsLocalInterpreter

use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter 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 3 with NodeJsLocalInterpreter

use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.

the class KarmaExecutionSession method createOSProcessHandler.

@NotNull
private OSProcessHandler createOSProcessHandler(@NotNull KarmaServer server, @NotNull File clientAppFile) throws ExecutionException {
    NodeJsLocalInterpreter interpreter = myRunSettings.getInterpreterRef().resolveAsLocal(myProject);
    GeneralCommandLine commandLine = createCommandLine(interpreter, server.getServerPort(), server.getKarmaConfig(), clientAppFile);
    OSProcessHandler processHandler = new KillableColoredProcessHandler(commandLine);
    server.getRestarter().onRunnerExecutionStarted(processHandler);
    ProcessTerminatedListener.attach(processHandler);
    mySmtConsoleView.attachToProcess(processHandler);
    return processHandler;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with NodeJsLocalInterpreter

use of com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter in project intellij-plugins by JetBrains.

the class KarmaRunConfiguration method getOrInitKarmaPackage.

@NotNull
private NodePackage getOrInitKarmaPackage() {
    NodePackage pkg = myRunSettings.getKarmaPackage();
    if (pkg == null) {
        Project project = getProject();
        NodeJsLocalInterpreter interpreter = NodeJsLocalInterpreter.tryCast(myRunSettings.getInterpreterRef().resolve(project));
        pkg = NodePackage.findPreferredPackage(project, KarmaUtil.NODE_PACKAGE_NAME, interpreter);
        if (!pkg.isEmptyPath() && !KarmaUtil.isPathUnderContentRoots(project, pkg)) {
            NodePackage projectKarmaPackage = KarmaProjectSettings.getKarmaPackage(project);
            if (projectKarmaPackage.isEmptyPath()) {
                KarmaProjectSettings.setKarmaPackage(project, pkg);
            }
            pkg = new NodePackage("");
        }
        myRunSettings = myRunSettings.toBuilder().setKarmaPackage(pkg).build();
    }
    return pkg;
}
Also used : Project(com.intellij.openapi.project.Project) NodePackage(com.intellij.javascript.nodejs.util.NodePackage) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NodeJsLocalInterpreter (com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter)4 NotNull (org.jetbrains.annotations.NotNull)3 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)2 KarmaServer (com.intellij.javascript.karma.server.KarmaServer)2 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)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 KarmaConfig (com.intellij.javascript.karma.KarmaConfig)1 KarmaScopeKind (com.intellij.javascript.karma.scope.KarmaScopeKind)1 KarmaServerRegistry (com.intellij.javascript.karma.server.KarmaServerRegistry)1 KarmaServerTerminatedListener (com.intellij.javascript.karma.server.KarmaServerTerminatedListener)1 KarmaTestProxyFilterProvider (com.intellij.javascript.karma.tree.KarmaTestProxyFilterProvider)1