use of org.jacoco.core.tools.ExecFileLoader in project bazel by bazelbuild.
the class JacocoCoverageRunner method create.
public void create() throws IOException {
// Read the jacoco.exec file. Multiple data files could be merged at this point
execFileLoader = new ExecFileLoader();
execFileLoader.load(executionData);
// Run the structure analyzer on a single class folder or jar file to build up the coverage
// model. Typically you would create a bundle for each class folder and each jar you want in
// your report. If you have more than one bundle you may need to add a grouping node to the
// report. The lcov formatter doesn't seem to care, and we're only using one bundle anyway.
final IBundleCoverage bundleCoverage = analyzeStructure();
final Map<String, BranchCoverageDetail> branchDetails = analyzeBranch();
createReport(bundleCoverage, branchDetails);
}
use of org.jacoco.core.tools.ExecFileLoader in project jacoco by jacoco.
the class DumpTask method execute.
@Override
public void execute() throws BuildException {
if (port <= 0) {
throw new BuildException("Invalid port value", getLocation());
}
if (dump && destfile == null) {
throw new BuildException("Destination file is required when dumping execution data", getLocation());
}
final ExecDumpClient client = new ExecDumpClient() {
@Override
protected void onConnecting(final InetAddress address, final int port) {
log(format("Connecting to %s:%s", address, Integer.valueOf(port)));
}
@Override
protected void onConnectionFailure(final IOException exception) {
log(exception.getMessage());
}
};
client.setDump(dump);
client.setReset(reset);
client.setRetryCount(retryCount);
try {
final ExecFileLoader loader = client.dump(address, port);
if (dump) {
log(format("Dumping execution data to %s", destfile.getAbsolutePath()));
loader.save(destfile, append);
}
} catch (final IOException e) {
throw new BuildException("Unable to dump coverage data", e, getLocation());
}
}
use of org.jacoco.core.tools.ExecFileLoader in project jacoco by jacoco.
the class ReportTask method loadExecutionData.
private void loadExecutionData() {
final ExecFileLoader loader = new ExecFileLoader();
for (final Iterator<?> i = executiondataElement.iterator(); i.hasNext(); ) {
final Resource resource = (Resource) i.next();
log(format("Loading execution data file %s", resource));
InputStream in = null;
try {
in = resource.getInputStream();
loader.load(in);
} catch (final IOException e) {
throw new BuildException(format("Unable to read execution data file %s", resource), e, getLocation());
} finally {
FileUtils.close(in);
}
}
sessionInfoStore = loader.getSessionInfoStore();
executionDataStore = loader.getExecutionDataStore();
}
use of org.jacoco.core.tools.ExecFileLoader in project jacoco by jacoco.
the class Dump method execute.
@Override
public int execute(final PrintWriter out, final PrintWriter err) throws Exception {
final ExecDumpClient client = new ExecDumpClient() {
@Override
protected void onConnecting(final InetAddress address, final int port) {
out.printf("[INFO] Connecting to %s:%s.%n", address, Integer.valueOf(port));
}
@Override
protected void onConnectionFailure(final IOException exception) {
err.printf("[WARN] %s.%n", exception.getMessage());
}
};
client.setReset(reset);
client.setRetryCount(retrycount);
final ExecFileLoader loader = client.dump(address, port);
out.printf("[INFO] Writing execution data to %s.%n", destfile.getAbsolutePath());
loader.save(destfile, true);
return 0;
}
use of org.jacoco.core.tools.ExecFileLoader in project jacoco by jacoco.
the class Merge method loadExecutionData.
private ExecFileLoader loadExecutionData(final PrintWriter out) throws IOException {
final ExecFileLoader loader = new ExecFileLoader();
if (execfiles.isEmpty()) {
out.println("[WARN] No execution data files provided.");
} else {
for (final File file : execfiles) {
out.printf("[INFO] Loading execution data file %s.%n", file.getAbsolutePath());
loader.load(file);
}
}
return loader;
}
Aggregations