use of org.jacoco.core.data.ExecutionData in project jacoco by jacoco.
the class Analyzer method createAnalyzingVisitor.
/**
* Creates an ASM class visitor for analysis.
*
* @param classid
* id of the class calculated with {@link CRC64}
* @param className
* VM name of the class
* @return ASM visitor to write class definition to
*/
private ClassVisitor createAnalyzingVisitor(final long classid, final String className) {
final ExecutionData data = executionData.get(classid);
final boolean[] probes;
final boolean noMatch;
if (data == null) {
probes = null;
noMatch = executionData.contains(className);
} else {
probes = data.getProbes();
noMatch = false;
}
final ClassCoverageImpl coverage = new ClassCoverageImpl(className, classid, noMatch);
final ClassAnalyzer analyzer = new ClassAnalyzer(coverage, probes, stringPool) {
@Override
public void visitEnd() {
super.visitEnd();
coverageVisitor.visitCoverage(coverage);
}
};
return new ClassProbesAdapter(analyzer, false);
}
use of org.jacoco.core.data.ExecutionData in project sonar-java by SonarSource.
the class ExecutionDataVisitorTest method test.
@Test
public void test() {
ExecutionDataVisitor visitor = new ExecutionDataVisitor();
visitor.visitSessionInfo(new SessionInfo("foo", 1L, 1L));
visitor.visitClassExecution(new ExecutionData(1, "", new boolean[] { true, false, false }));
visitor.visitSessionInfo(new SessionInfo("bar", 2L, 2L));
visitor.visitClassExecution(new ExecutionData(1, "", new boolean[] { false, true, false }));
visitor.visitSessionInfo(new SessionInfo("foo", 3L, 3L));
visitor.visitClassExecution(new ExecutionData(1, "", new boolean[] { false, false, true }));
assertThat(visitor.getSessions()).hasSize(2);
assertThat(visitor.getSessions().get("foo").getContents()).hasSize(1);
assertThat(visitor.getSessions().get("foo").get(1).getProbes()).isEqualTo(new boolean[] { true, false, true });
assertThat(visitor.getSessions().get("bar").getContents()).hasSize(1);
assertThat(visitor.getSessions().get("bar").get(1).getProbes()).isEqualTo(new boolean[] { false, true, false });
assertThat(visitor.getMerged().get(1).getProbes()).isEqualTo(new boolean[] { true, true, true });
}
Aggregations