Search in sources :

Example 6 with ExecutionData

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

the class SessionsPage method executionDataTable.

private void executionDataTable(final HTMLElement body) throws IOException {
    final HTMLElement table = body.table(Styles.COVERAGETABLE);
    {
        final HTMLElement tr = table.thead().tr();
        tr.td().text("Class");
        tr.td().text("Id");
    }
    final HTMLElement tbody = table.tbody();
    final ILanguageNames names = context.getLanguageNames();
    for (final ExecutionData e : executionData) {
        final HTMLElement tr = tbody.tr();
        final String link = index.getLinkToClass(e.getId());
        final String qualifiedName = names.getQualifiedClassName(e.getName());
        if (link == null) {
            tr.td().span(Styles.EL_CLASS).text(qualifiedName);
        } else {
            tr.td().a(link, Styles.EL_CLASS).text(qualifiedName);
        }
        final String id = String.format("%016x", Long.valueOf(e.getId()));
        tr.td().code().text(id);
    }
}
Also used : HTMLElement(org.jacoco.report.internal.html.HTMLElement) ILanguageNames(org.jacoco.report.ILanguageNames) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 7 with ExecutionData

use of org.jacoco.core.data.ExecutionData 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 8 with ExecutionData

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

the class ExecFileLoaderTest method createFile.

private File createFile(String id) throws IOException {
    final File file = new File(sourceFolder.getRoot(), id + ".exec");
    final FileOutputStream out = new FileOutputStream(file);
    final ExecutionDataWriter writer = new ExecutionDataWriter(out);
    final int value = id.length();
    writer.visitClassExecution(new ExecutionData(value, id, new boolean[] { true }));
    writer.visitSessionInfo(new SessionInfo(id, value, value));
    out.close();
    return file;
}
Also used : FileOutputStream(java.io.FileOutputStream) SessionInfo(org.jacoco.core.data.SessionInfo) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) File(java.io.File) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 9 with ExecutionData

use of org.jacoco.core.data.ExecutionData in project sonar-java by SonarSource.

the class UnitTestAnalyzer method classFilesOfStore.

private Collection<File> classFilesOfStore(ExecutionDataStore executionDataStore) {
    Collection<File> result = Lists.newArrayList();
    for (ExecutionData data : executionDataStore.getContents()) {
        String vmClassName = data.getName();
        File classFile = classFilesCache.get(vmClassName);
        if (classFile != null) {
            result.add(classFile);
        }
    }
    return result;
}
Also used : InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) ExecutionData(org.jacoco.core.data.ExecutionData)

Example 10 with ExecutionData

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

the class CreateExecFiles method main.

public static void main(String[] args) throws IOException {
    OutputStream out;
    out = new FileOutputStream(BASE_LOCATION + "sample1.exec");
    new ExecutionDataWriter(out);
    out.close();
    out = new FileOutputStream(BASE_LOCATION + "sample2.exec");
    new ExecutionDataWriter(out);
    out.close();
    out = new FileOutputStream(BASE_LOCATION + "nomatch.exec");
    ExecutionDataWriter writer = new ExecutionDataWriter(out);
    writer.visitClassExecution(new ExecutionData(0, "org/jacoco/ant/TestTarget", new boolean[0]));
    out.close();
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ExecutionDataWriter(org.jacoco.core.data.ExecutionDataWriter) ExecutionData(org.jacoco.core.data.ExecutionData)

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