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);
}
});
}
}
});
}
});
}
}
Aggregations