Search in sources :

Example 6 with Analyzer

use of org.jacoco.core.analysis.Analyzer in project jacoco by jacoco.

the class ValidationTestBase method analyze.

private void analyze(final ExecutionDataStore store) throws IOException {
    final CoverageBuilder builder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(store, builder);
    for (ExecutionData data : store.getContents()) {
        analyze(analyzer, data);
    }
    String srcName = target.getName().replace('.', '/') + ".java";
    for (ISourceFileCoverage file : builder.getSourceFiles()) {
        if (srcName.equals(file.getPackageName() + "/" + file.getName())) {
            sourceCoverage = file;
            return;
        }
    }
    fail("No source node found for " + srcName);
}
Also used : ISourceFileCoverage(org.jacoco.core.analysis.ISourceFileCoverage) CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 7 with Analyzer

use of org.jacoco.core.analysis.Analyzer in project dspot by STAMP-project.

the class JacocoListener method coverageResults.

private CoverageResults coverageResults(ExecutionDataStore executionData) {
    final CoverageBuilder coverageBuilder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);
    try {
        analyzer.analyzeAll(new File(classesDirectory));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return new CoverageResults(coverageBuilder);
}
Also used : CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) IOException(java.io.IOException) Analyzer(org.jacoco.core.analysis.Analyzer) File(java.io.File)

Example 8 with Analyzer

use of org.jacoco.core.analysis.Analyzer in project sonar-java by SonarSource.

the class JacocoReportReader method analyzeFiles.

/**
 * Caller must guarantee that {@code classFiles} are actually class file.
 */
public CoverageBuilder analyzeFiles(ExecutionDataStore executionDataStore, Collection<File> classFiles) {
    CoverageBuilder coverageBuilder = new CoverageBuilder();
    if (useCurrentBinaryFormat) {
        Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
        for (File classFile : classFiles) {
            analyzeClassFile(analyzer, classFile);
        }
    } else {
        org.jacoco.previous.core.analysis.Analyzer analyzer = new org.jacoco.previous.core.analysis.Analyzer(executionDataStore, coverageBuilder);
        for (File classFile : classFiles) {
            analyzeClassFile(analyzer, classFile);
        }
    }
    logNoMatchClasses(coverageBuilder.getNoMatchClasses());
    return coverageBuilder;
}
Also used : CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer) File(java.io.File)

Example 9 with Analyzer

use of org.jacoco.core.analysis.Analyzer in project bazel by bazelbuild.

the class JacocoCoverageRunner method analyzeStructure.

private IBundleCoverage analyzeStructure() throws IOException {
    final CoverageBuilder coverageBuilder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(execFileLoader.getExecutionDataStore(), coverageBuilder);
    for (File classesJar : classesJars) {
        analyzer.analyzeAll(classesJar);
    }
    // TODO(bazel-team): Find out where the name of the bundle can pop out in the report.
    return coverageBuilder.getBundle("isthisevenused");
}
Also used : CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer) File(java.io.File)

Example 10 with Analyzer

use of org.jacoco.core.analysis.Analyzer in project powermock by powermock.

the class JacocoCoverageTest method collectCoverage.

private CoverageBuilder collectCoverage(ExecutionDataStore executionData) throws IOException {
    final CoverageBuilder coverageBuilder = new CoverageBuilder();
    final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);
    for (String className : TARGET) {
        analyzer.analyzeClass(getClass().getResourceAsStream(classNameToFileName(className)), className);
    }
    return coverageBuilder;
}
Also used : CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Analyzer(org.jacoco.core.analysis.Analyzer)

Aggregations

Analyzer (org.jacoco.core.analysis.Analyzer)14 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)13 File (java.io.File)7 IClassCoverage (org.jacoco.core.analysis.IClassCoverage)3 ExecutionDataStore (org.jacoco.core.data.ExecutionDataStore)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 IBundleCoverage (org.jacoco.core.analysis.IBundleCoverage)2 SessionInfoStore (org.jacoco.core.data.SessionInfoStore)2 Callable (java.util.concurrent.Callable)1 Resource (org.apache.tools.ant.types.Resource)1 FileResource (org.apache.tools.ant.types.resources.FileResource)1 ICoverageVisitor (org.jacoco.core.analysis.ICoverageVisitor)1 IMethodCoverage (org.jacoco.core.analysis.IMethodCoverage)1 ISourceFileCoverage (org.jacoco.core.analysis.ISourceFileCoverage)1 ExecutionData (org.jacoco.core.data.ExecutionData)1 Instrumenter (org.jacoco.core.instr.Instrumenter)1 IRuntime (org.jacoco.core.runtime.IRuntime)1 LoggerRuntime (org.jacoco.core.runtime.LoggerRuntime)1 RuntimeData (org.jacoco.core.runtime.RuntimeData)1