use of org.jacoco.report.FileMultiReportOutput in project buck by facebook.
the class ReportGenerator method createReport.
private void createReport(final IBundleCoverage bundleCoverage) throws IOException {
// Create a concrete report visitor based on some supplied
// configuration. In this case we use the defaults
IReportVisitor visitor;
switch(reportFormat) {
case "csv":
reportDirectory.mkdirs();
CSVFormatter csvFormatter = new CSVFormatter();
visitor = csvFormatter.createVisitor(new FileOutputStream(new File(reportDirectory, "coverage.csv")));
break;
case "html":
HTMLFormatter htmlFormatter = new HTMLFormatter();
visitor = htmlFormatter.createVisitor(new FileMultiReportOutput(reportDirectory));
break;
case "xml":
reportDirectory.mkdirs();
XMLFormatter xmlFormatter = new XMLFormatter();
visitor = xmlFormatter.createVisitor(new FileOutputStream(new File(reportDirectory, "coverage.xml")));
break;
default:
throw new RuntimeException("Unable to parse format: " + reportFormat);
}
// Initialize the report with all of the execution and session
// information. At this point the report doesn't know about the
// structure of the report being created
visitor.visitInfo(execFileLoader.getSessionInfoStore().getInfos(), execFileLoader.getExecutionDataStore().getContents());
// Populate the report structure with the bundle coverage information.
// Call visitGroup if you need groups in your report.
visitor.visitBundle(bundleCoverage, createSourceFileLocator());
// Signal end of structure information to allow report to write all
// information out
visitor.visitEnd();
}
use of org.jacoco.report.FileMultiReportOutput in project jacoco by jacoco.
the class Report method createReportVisitor.
private IReportVisitor createReportVisitor() throws IOException, IOException {
final List<IReportVisitor> visitors = new ArrayList<IReportVisitor>();
if (xml != null) {
final XMLFormatter formatter = new XMLFormatter();
visitors.add(formatter.createVisitor(new FileOutputStream(xml)));
}
if (csv != null) {
final CSVFormatter formatter = new CSVFormatter();
visitors.add(formatter.createVisitor(new FileOutputStream(csv)));
}
if (html != null) {
final HTMLFormatter formatter = new HTMLFormatter();
visitors.add(formatter.createVisitor(new FileMultiReportOutput(html)));
}
return new MultiReportVisitor(visitors);
}
use of org.jacoco.report.FileMultiReportOutput in project jacoco by jacoco.
the class ReportGenerator method createReport.
private void createReport(final IBundleCoverage bundleCoverage) throws IOException {
// Create a concrete report visitor based on some supplied
// configuration. In this case we use the defaults
final HTMLFormatter htmlFormatter = new HTMLFormatter();
final IReportVisitor visitor = htmlFormatter.createVisitor(new FileMultiReportOutput(reportDirectory));
// Initialize the report with all of the execution and session
// information. At this point the report doesn't know about the
// structure of the report being created
visitor.visitInfo(execFileLoader.getSessionInfoStore().getInfos(), execFileLoader.getExecutionDataStore().getContents());
// Populate the report structure with the bundle coverage information.
// Call visitGroup if you need groups in your report.
visitor.visitBundle(bundleCoverage, new DirectorySourceFileLocator(sourceDirectory, "utf-8", 4));
// Signal end of structure information to allow report to write all
// information out
visitor.visitEnd();
}
use of org.jacoco.report.FileMultiReportOutput in project jacoco by jacoco.
the class ReportSupport method addHtmlFormatter.
public void addHtmlFormatter(final File targetdir, final String encoding, final String footer, final Locale locale) throws IOException {
final HTMLFormatter htmlFormatter = new HTMLFormatter();
htmlFormatter.setOutputEncoding(encoding);
htmlFormatter.setLocale(locale);
if (footer != null) {
htmlFormatter.setFooterText(footer);
}
formatters.add(htmlFormatter.createVisitor(new FileMultiReportOutput(targetdir)));
}
Aggregations