@Test public void should_ignore_and_log_warning_for_invalid_line() { settings.setProperty(JavaScriptPlugin.LCOV_REPORT_PATHS, "reports/wrong_line_report.lcov"); coverageSensor.execute(context); assertThat(context.lineHits("moduleKey:file1.js", 0)).isNull(); assertThat(context.lineHits("moduleKey:file1.js", 2)).isEqualTo(1); assertThat(context.conditions("moduleKey:file1.js", 102)).isNull(); assertThat(context.conditions("moduleKey:file1.js", 2)).isEqualTo(3); assertThat(context.coveredConditions("moduleKey:file1.js", 2)).isEqualTo(1); assertThat(logTester.logs()).contains("Problem during processing LCOV report: can't save DA data for line 3 of coverage report file (java.lang.IllegalArgumentException: Line with number 0 doesn't belong to file file1.js)."); assertThat(logTester.logs()).contains("Problem during processing LCOV report: can't save BRDA data for line 8 of coverage report file (java.lang.IllegalArgumentException: Line with number 102 doesn't belong to file file1.js)."); }
@Override public void execute(SensorContext context) { Set<String> reports = new HashSet<>(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS))); if (context.config().hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) { LOG.warn("The use of " + JavaScriptPlugin.TS_LCOV_REPORT_PATHS + " for coverage import is deprecated, use " + JavaScriptPlugin.LCOV_REPORT_PATHS + " instead."); reports.addAll(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.TS_LCOV_REPORT_PATHS))); } List<File> lcovFiles = reports.stream() .map(report -> getIOFile(context.fileSystem().baseDir(), report)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (lcovFiles.isEmpty()) { LOG.warn("No coverage information will be saved because all LCOV files cannot be found."); return; } saveCoverageFromLcovFiles(context, lcovFiles); }
CoverageSensor implements Sensor { @Override public void execute(SensorContext context) { Set<String> reports = new HashSet<>(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS))); if (context.config().hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) { LOG.warn("The use of " + JavaScriptPlugin.TS_LCOV_REPORT_PATHS + " for coverage import is deprecated, use " + JavaScriptPlugin.LCOV_REPORT_PATHS + " instead."); reports.addAll(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.TS_LCOV_REPORT_PATHS))); } List<File> lcovFiles = reports.stream() .map(report -> getIOFile(context.fileSystem().baseDir(), report)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (lcovFiles.isEmpty()) { LOG.warn("No coverage information will be saved because all LCOV files cannot be found."); return; } saveCoverageFromLcovFiles(context, lcovFiles); } }
CoverageSensor implements Sensor { @Override public void execute(SensorContext context) { Set<String> reports = new HashSet<>(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS))); if (context.config().hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) { LOG.warn("The use of " + JavaScriptPlugin.TS_LCOV_REPORT_PATHS + " for coverage import is deprecated, use " + JavaScriptPlugin.LCOV_REPORT_PATHS + " instead."); reports.addAll(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.TS_LCOV_REPORT_PATHS))); } List<File> lcovFiles = reports.stream() .map(report -> getIOFile(context.fileSystem().baseDir(), report)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (lcovFiles.isEmpty()) { LOG.warn("No coverage information will be saved because all LCOV files cannot be found."); return; } saveCoverageFromLcovFiles(context, lcovFiles); }  }
CoverageSensor implements Sensor { @Override public void execute(SensorContext context) { Set<String> reports = new HashSet<>(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS))); if (context.config().hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) { LOG.warn("The use of " + JavaScriptPlugin.TS_LCOV_REPORT_PATHS + " for coverage import is deprecated, use " + JavaScriptPlugin.LCOV_REPORT_PATHS + " instead."); reports.addAll(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.TS_LCOV_REPORT_PATHS))); } List<File> lcovFiles = reports.stream() .map(report -> getIOFile(context.fileSystem().baseDir(), report)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (lcovFiles.isEmpty()) { LOG.warn("No coverage information will be saved because all LCOV files cannot be found."); return; } saveCoverageFromLcovFiles(context, lcovFiles); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
CoverageSensor implements Sensor { @Override public void execute(SensorContext context) { Set<String> reports = new HashSet<>(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.LCOV_REPORT_PATHS))); if (context.config().hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) { LOG.warn("The use of " + JavaScriptPlugin.TS_LCOV_REPORT_PATHS + " for coverage import is deprecated, use " + JavaScriptPlugin.LCOV_REPORT_PATHS + " instead."); reports.addAll(Arrays.asList(context.config().getStringArray(JavaScriptPlugin.TS_LCOV_REPORT_PATHS))); } List<File> lcovFiles = reports.stream() .map(report -> getIOFile(context.fileSystem().baseDir(), report)) .filter(Objects::nonNull) .collect(Collectors.toList()); if (lcovFiles.isEmpty()) { LOG.warn("No coverage information will be saved because all LCOV files cannot be found."); return; } saveCoverageFromLcovFiles(context, lcovFiles); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }