use of org.jacoco.core.data.IExecutionDataVisitor in project jacoco by jacoco.
the class ExecInfo method dump.
private void dump(final File file, final PrintWriter out) throws IOException {
out.printf("[INFO] Loading exec file %s.%n", file);
out.println("CLASS ID HITS/PROBES CLASS NAME");
final FileInputStream in = new FileInputStream(file);
final ExecutionDataReader reader = new ExecutionDataReader(in);
reader.setSessionInfoVisitor(new ISessionInfoVisitor() {
public void visitSessionInfo(final SessionInfo info) {
out.printf("Session \"%s\": %s - %s%n", info.getId(), new Date(info.getStartTimeStamp()), new Date(info.getDumpTimeStamp()));
}
});
reader.setExecutionDataVisitor(new IExecutionDataVisitor() {
public void visitClassExecution(final ExecutionData data) {
out.printf("%016x %3d of %3d %s%n", Long.valueOf(data.getId()), Integer.valueOf(getHitCount(data.getProbes())), Integer.valueOf(data.getProbes().length), data.getName());
}
});
reader.read();
in.close();
out.println();
}
use of org.jacoco.core.data.IExecutionDataVisitor in project jacoco by jacoco.
the class ExecDump method dump.
private void dump(final String file) throws IOException {
out.printf("exec file: %s%n", file);
out.println("CLASS ID HITS/PROBES CLASS NAME");
final FileInputStream in = new FileInputStream(file);
final ExecutionDataReader reader = new ExecutionDataReader(in);
reader.setSessionInfoVisitor(new ISessionInfoVisitor() {
public void visitSessionInfo(final SessionInfo info) {
out.printf("Session \"%s\": %s - %s%n", info.getId(), new Date(info.getStartTimeStamp()), new Date(info.getDumpTimeStamp()));
}
});
reader.setExecutionDataVisitor(new IExecutionDataVisitor() {
public void visitClassExecution(final ExecutionData data) {
out.printf("%016x %3d of %3d %s%n", Long.valueOf(data.getId()), Integer.valueOf(getHitCount(data.getProbes())), Integer.valueOf(data.getProbes().length), data.getName());
}
});
reader.read();
in.close();
out.println();
}
use of org.jacoco.core.data.IExecutionDataVisitor in project sonar-java by SonarSource.
the class JaCoCoReportMerger method mergeReports.
/**
* Merge all reports in reportOverall.
* @param reportOverall destination file of merge.
* @param reports files to be merged.
*/
public static void mergeReports(File reportOverall, File... reports) {
ExecutionDataVisitor edv = new ExecutionDataVisitor();
boolean isCurrentVersionFormat = loadSourceFiles(edv, reports);
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(reportOverall))) {
Object visitor;
if (isCurrentVersionFormat) {
visitor = new ExecutionDataWriter(outputStream);
} else {
visitor = new org.jacoco.previous.core.data.ExecutionDataWriter(outputStream);
}
for (Map.Entry<String, ExecutionDataStore> entry : edv.getSessions().entrySet()) {
SessionInfo sessionInfo = new SessionInfo(entry.getKey(), 0, 0);
((ISessionInfoVisitor) visitor).visitSessionInfo(sessionInfo);
entry.getValue().accept((IExecutionDataVisitor) visitor);
}
} catch (IOException e) {
throw new AnalysisException(String.format("Unable to write overall coverage report %s", reportOverall.getAbsolutePath()), e);
}
}
Aggregations