@Test public void should_resolve_absolute_path() throws Exception { File lcovFile = temp.newFile(); String absolutePathFile1 = new File("src/test/resources/coverage/file1.js").getAbsolutePath(); String absolutePathFile2 = new File("src/test/resources/coverage/file2.js").getAbsolutePath(); FileUtils.writeStringToFile(lcovFile, "SF:" + absolutePathFile1 + "\n" + "DA:1,2\n" + "DA:2,2\n" + "DA:3,1\n" + "FN:2,(anonymous_1)\n" + "FNDA:2,(anonymous_1)\n" + "BRDA:2,1,0,2\n" + "BRDA:2,1,1,1\n" + "BRDA:2,2,0,0\n" + "BRDA:2,2,1,-\n" + "end_of_record\n" + "SF:" + absolutePathFile2 + "\n" + "DA:1,5\n" + "DA:2,5\n" + "end_of_record\n", "UTF-8", false); settings.setProperty(JavaScriptPlugin.LCOV_REPORT_PATHS, lcovFile.getAbsolutePath()); inputFile("file1.js", Type.MAIN); inputFile("file2.js", Type.MAIN); coverageSensor.execute(context); String file1Key = "moduleKey:file1.js"; assertThat(context.lineHits(file1Key, 0)).isNull(); assertThat(context.lineHits(file1Key, 1)).isEqualTo(2); assertThat(context.lineHits(file1Key, 2)).isEqualTo(2); assertThat(context.conditions(file1Key, 102)).isNull(); assertThat(context.conditions(file1Key, 2)).isEqualTo(4); assertThat(context.coveredConditions(file1Key, 2)).isEqualTo(2); String file2Key = "moduleKey:file2.js"; assertThat(context.lineHits(file2Key, 0)).isNull(); assertThat(context.lineHits(file2Key, 1)).isEqualTo(5); assertThat(context.lineHits(file2Key, 2)).isEqualTo(5); }
@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);  }