Search in sources :

Example 1 with ExecutionData

use of org.jacoco.core.data.ExecutionData in project bazel by bazelbuild.

the class BranchDetailAnalyzer method analyzeClass.

@Override
public void analyzeClass(final ClassReader reader) {
    final Map<Integer, BranchExp> lineToBranchExp = mapProbes(reader);
    long classid = CRC64.checksum(reader.b);
    ExecutionData classData = executionData.get(classid);
    if (classData == null) {
        return;
    }
    boolean[] probes = classData.getProbes();
    BranchCoverageDetail detail = new BranchCoverageDetail();
    for (Map.Entry<Integer, BranchExp> entry : lineToBranchExp.entrySet()) {
        int line = entry.getKey();
        BranchExp branchExp = entry.getValue();
        List<CovExp> branches = branchExp.getBranches();
        detail.setBranches(line, branches.size());
        for (int branchIdx = 0; branchIdx < branches.size(); branchIdx++) {
            if (branches.get(branchIdx).eval(probes)) {
                detail.setTakenBit(line, branchIdx);
            }
        }
    }
    if (detail.linesWithBranches().size() > 0) {
        branchDetails.put(reader.getClassName(), detail);
    }
}
Also used : TreeMap(java.util.TreeMap) Map(java.util.Map) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 2 with ExecutionData

use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.

the class MergeTest method createExecFile.

private File createExecFile(String name) throws IOException {
    File file = new File(tmp.getRoot(), name + ".exec");
    final FileOutputStream execout = new FileOutputStream(file);
    ExecutionDataWriter writer = new ExecutionDataWriter(execout);
    writer.visitClassExecution(new ExecutionData(name.hashCode(), name, new boolean[] { true }));
    execout.close();
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) File(java.io.File) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 3 with ExecutionData

use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.

the class MergeTest method loadExecFile.

private Set<String> loadExecFile(File file) throws IOException {
    ExecFileLoader loader = new ExecFileLoader();
    loader.load(file);
    Set<String> names = new HashSet<String>();
    for (ExecutionData d : loader.getExecutionDataStore().getContents()) {
        names.add(d.getName());
    }
    return names;
}
Also used : ExecFileLoader(org.jacoco.core.tools.ExecFileLoader) HashSet(java.util.HashSet) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 4 with ExecutionData

use of org.jacoco.core.data.ExecutionData 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();
}
Also used : ISessionInfoVisitor(org.jacoco.core.data.ISessionInfoVisitor) SessionInfo(org.jacoco.core.data.SessionInfo) IExecutionDataVisitor(org.jacoco.core.data.IExecutionDataVisitor) FileInputStream(java.io.FileInputStream) Date(java.util.Date) ExecutionDataReader(org.jacoco.core.data.ExecutionDataReader) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 5 with ExecutionData

use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.

the class XMLFormatterTest method setup.

@Before
public void setup() {
    driver = new ReportStructureTestDriver();
    formatter = new XMLFormatter();
    output = new MemoryOutput();
    infos = new ArrayList<SessionInfo>();
    data = new ArrayList<ExecutionData>();
}
Also used : SessionInfo(org.jacoco.core.data.SessionInfo) MemoryOutput(org.jacoco.report.MemoryOutput) ReportStructureTestDriver(org.jacoco.report.ReportStructureTestDriver) ExecutionData(org.jacoco.core.data.ExecutionData) Before(org.junit.Before)

Aggregations

ExecutionData (org.jacoco.core.data.ExecutionData)17 SessionInfo (org.jacoco.core.data.SessionInfo)7 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 ExecutionDataWriter (org.jacoco.core.data.ExecutionDataWriter)6 Test (org.junit.Test)3 FileInputStream (java.io.FileInputStream)2 Date (java.util.Date)2 ExecutionDataReader (org.jacoco.core.data.ExecutionDataReader)2 IExecutionDataVisitor (org.jacoco.core.data.IExecutionDataVisitor)2 ISessionInfoVisitor (org.jacoco.core.data.ISessionInfoVisitor)2 HTMLElement (org.jacoco.report.internal.html.HTMLElement)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Analyzer (org.jacoco.core.analysis.Analyzer)1 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)1