Search in sources :

Example 1 with KarmaRunConfiguration

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

the class KarmaCoverageProgramRunner method listenForCoverageFile.

private static void listenForCoverageFile(@NotNull ExecutionEnvironment env, @NotNull KarmaServer server) throws ExecutionException {
    KarmaRunConfiguration runConfiguration = (KarmaRunConfiguration) env.getRunProfile();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    CoverageHelper.resetCoverageSuit(runConfiguration);
    String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
    if (coverageFilePath != null) {
        KarmaCoveragePeer coveragePeer = server.getCoveragePeer();
        Objects.requireNonNull(coveragePeer);
        coveragePeer.startCoverageSession(new KarmaCoverageSession() {

            @Override
            public void onCoverageSessionFinished(@Nullable File lcovFile) {
                LOG.info("Processing karma coverage file: " + lcovFile);
                UIUtil.invokeLaterIfNeeded(() -> {
                    Project project = env.getProject();
                    if (project.isDisposed())
                        return;
                    if (lcovFile != null) {
                        processLcovInfoFile(lcovFile, coverageFilePath, env, server, runConfiguration);
                    } else {
                        int response = Messages.showYesNoDialog(project, "Cannot find karma test coverage report - lcov.info", "Missing Karma Coverage Report", "Select lcov.info", "Cancel", Messages.getWarningIcon());
                        if (response == Messages.YES) {
                            FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileDescriptor(), project, null, null, file -> {
                                File selected = file != null ? VfsUtilCore.virtualToIoFile(file) : null;
                                if (selected != null) {
                                    processLcovInfoFile(selected, coverageFilePath, env, server, runConfiguration);
                                }
                            });
                        }
                    }
                });
            }
        });
    }
}
Also used : KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) KarmaUtil(com.intellij.javascript.karma.util.KarmaUtil) KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) UIUtil(com.intellij.util.ui.UIUtil) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) ExecutionException(com.intellij.execution.ExecutionException) CoverageHelper(com.intellij.coverage.CoverageHelper) RunProfileState(com.intellij.execution.configurations.RunProfileState) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Project(com.intellij.openapi.project.Project) ExecutionResult(com.intellij.execution.ExecutionResult) Messages(com.intellij.openapi.ui.Messages) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) CoverageRunnerData(com.intellij.coverage.CoverageRunnerData) ConfigurationInfoProvider(com.intellij.execution.configurations.ConfigurationInfoProvider) GenericProgramRunner(com.intellij.execution.runners.GenericProgramRunner) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) CoverageDataManager(com.intellij.coverage.CoverageDataManager) RunProfile(com.intellij.execution.configurations.RunProfile) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IOException(java.io.IOException) RunnerSettings(com.intellij.execution.configurations.RunnerSettings) File(java.io.File) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) CoverageExecutor(com.intellij.coverage.CoverageExecutor) ExecutionUtil(com.intellij.execution.runners.ExecutionUtil) KarmaConsoleView(com.intellij.javascript.karma.execution.KarmaConsoleView) NotNull(org.jetbrains.annotations.NotNull) FileChooser(com.intellij.openapi.fileChooser.FileChooser) Project(com.intellij.openapi.project.Project) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) File(java.io.File)

Aggregations

CoverageDataManager (com.intellij.coverage.CoverageDataManager)1 CoverageExecutor (com.intellij.coverage.CoverageExecutor)1 CoverageHelper (com.intellij.coverage.CoverageHelper)1 CoverageRunnerData (com.intellij.coverage.CoverageRunnerData)1 ExecutionException (com.intellij.execution.ExecutionException)1 ExecutionResult (com.intellij.execution.ExecutionResult)1 ConfigurationInfoProvider (com.intellij.execution.configurations.ConfigurationInfoProvider)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 RunProfileState (com.intellij.execution.configurations.RunProfileState)1 RunnerSettings (com.intellij.execution.configurations.RunnerSettings)1 CoverageEnabledConfiguration (com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 ExecutionUtil (com.intellij.execution.runners.ExecutionUtil)1 GenericProgramRunner (com.intellij.execution.runners.GenericProgramRunner)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 KarmaConsoleView (com.intellij.javascript.karma.execution.KarmaConsoleView)1 KarmaRunConfiguration (com.intellij.javascript.karma.execution.KarmaRunConfiguration)1 KarmaServer (com.intellij.javascript.karma.server.KarmaServer)1 KarmaUtil (com.intellij.javascript.karma.util.KarmaUtil)1 Logger (com.intellij.openapi.diagnostic.Logger)1