Commandline merging of results and report generator

1,190 views
Skip to first unread message

judovana

unread,
Nov 19, 2012, 1:44:35 PM11/19/12
to jac...@googlegroups.com
Hi!

I'm migrating our project (icedtea-web) from emma to jacoco. It have "make" build/testing system. The coverage run itself is running pretty fine all unit and integration tests (grate job guys!).
I was used to call commandline application to merge results from integration and unit-tests results, and also for generating individual  and merged (xml+html) results.

I have not found this in jacoco. I have found only html generator class example. Before getting more into java-based api (and so write my own commandline-based main class/jar), can you confirm there is nothing like commandline tool for this task?
(I guess no:( )
Also for merging I have found no example. Can you guide me a bit?

Best regards,
   J

Marc R. Hoffmann

unread,
Nov 19, 2012, 4:12:06 PM11/19/12
to jac...@googlegroups.com
Hi,

you're observation is correct, there is no out-of-the-box command line
tool to merge exe files.

As an implementation example you might take a look at the Ant task
implementation -- it's actually quite simple:

https://github.com/jacoco/jacoco/blob/76f62ca24023d3522cfd806ff471e90e4f286739/org.jacoco.ant/src/org/jacoco/ant/MergeTask.java

Best regards,
-marc
> --

judovana

unread,
Nov 20, 2012, 11:17:14 AM11/20/12
to jac...@googlegroups.com
Thank you very much for your quick answer.

Both Html generator example and AntMergeTask cases are excelent startpoints and are working (mostly:) well

I have elaborated a bit more, and I got confused on situation when my class files and source files are wide spread all over the different sources tree and over different build trees

xml report - i do not want to add sourcefiles  - when :
    - no visitor.visitBundle is caled, then empty report is generated
    - if  visitor.visitBundle(bundleCoverage, null); is called, then report is generated, including sourceFiles elements (but those comes from clas files I guess)
    - if  visitor.visitBundle(bundleCoverage, somethng) is called more then once, generation fails, with java.io.IOException: Element report already closed.
   => sources have no efect to xml report? Can I somehow disable "sourcefile" infromation?
 
Do I read correctly xml, that there are always  <counter type missed covered> for each method, then sumary for each package and at hte end for whole session/run?  What is difference betwen COUNTER element when appearing in class element end when in sourcefille element (of same name but suffix)?


html report -  when I run :
for (File file : classesDirectories) {             analyzer.analyzeAll(file);        } then it looks like multiple classes directories/jars are scanned correctly.
(wehre  CoverageBuilder coverageBuilder = new CoverageBuilder() and   Analyzer analyzer = new Analyzer(executionDataStore,coverageBuilder);

but for:  for (File file : sourceDirectories) {visitor.visitBundle(bundleCoverage, new DirectorySourceFileLocator(file, "utf-8", 4));}
           where IReportVisitor visitor = htmlFormatter.createVisitor(new FileMultiReportOutput(reportDirectory));
   It looks to me like only always LAST surce is only propagated into html report :(


Can you point me where I'm going wrong?

Marc R. Hoffmann

unread,
Nov 20, 2012, 1:30:37 PM11/20/12
to jac...@googlegroups.com
Hi,

I'm not sure whether I understand all your questions correctly, but here
are some facts about the reporting API:

* The XML and CSV formatter does not use sources at all.

* A single Java source file may contain multiple classes (inner classes
and secondary classes). That's why there are separate counters for
classes and source files in the XML report.

* If you want to lookup sources from multiple directories, you must not
generate the report multiple times. Instead you need a
ISourceFileLocator implementation that searches class files at multiple
locations. For this the MultiSourceFileLocator implementation is provided.

I hope this clarifies some of your issues.

Best regards,
-marc

judovana

unread,
Nov 23, 2012, 12:23:07 PM11/23/12
to JaCoCo and EclEmma Users
Thank you very much , yes it clarified stuff a lot. Sorry for delayed
reply but I had some work to fix how jacoco is packed for fedora.

Jacoco is right now working well for unit--tests and "My application"
is providing nice comfortable merge and html+xml reporting.

However for integration tests I have run into interesting problem:
Icedtea-web is opensource version of javaws, so ti si java application
which is launching another java applications.
When I attach jacoco agent to this process, then application I'm
running in icedtea-web have measured coverage prety well, but no class
form icedtea-web itself is covered :(
Can it be caused by Xbootclaspath where whole icedtea-web is settled?

You can see our javaws launcher here:
http://icedtea.classpath.org/hg/icedtea-web/file/a1112e2c3bc6/launcher/javaws.in
During measuring of coverage by some reproducer I modify above file
just by agent and xbootclasspath so two lines changes eg like this:
...
LAUNCHER_BOOTCLASSPATH="-Xbootclasspath/a:/home/jvanek/icedtea-web-
image/share/icedtea-web/netx.jar:/usr/share/java/js.jar:/usr/share/
java/jacoco/org.jacoco.core.jar:/usr/share/java/jacoco/
org.jacoco.agent.jar:/usr/share/java/jacoco/org.jacoco.report.jar:/usr/
share/java/jacoco/org.jacoco.agent.rt.jar:/usr/share/java/jacoco/
org.jacoco.ant.jar:/usr/share/java/objectweb-asm/asm-all.jar"
...
COMMAND[k]="${JAVA}" ; k=1 ; COMMAND[k]="-javaagent:/usr/share/java/
jacoco/
org.jacoco.agent.rt.jar=excludes=org.junit.*:junit.*,destfile=jacoco_manual.exec"
...


I will soon push this report-generating/merging tool to icedtea-web
repository, and I was thinking if it is not worthy to push it rather
to jacoco upstream? I guess there must be need for such a tool.
If there can be need for such a command line middle man in jacoco
team, then I will point you to the icedtea-web push later, or I can
send this "application" for review and potential inclusion to jacoco
team itself.

Best regards, J






On Nov 20, 1:30 pm, "Marc R. Hoffmann" <hoffm...@mountainminds.com>
wrote:
> >    https://github.com/jacoco/jacoco/blob/76f62ca24023d3522cfd806ff471e90...
> >     <https://github.com/jacoco/jacoco/blob/76f62ca24023d3522cfd806ff471e90...>

judovana

unread,
Nov 26, 2012, 11:29:17 AM11/26/12
to jac...@googlegroups.com

Fact that all classes are not covered I consider as intentional on side of jacoco and so I have created new thread for this.
Thank you for all your help on command line tool topic.

If jacoco project will want such a commandline tool, I would like to contribute by this $0.02 and also maintain this three classes a bit.

Marc Hoffmann

unread,
Nov 26, 2012, 11:59:44 AM11/26/12
to jac...@googlegroups.com
Hi,

the JaCoCo does not instrument system classes, as JaCoCo itself depends
on the Java runtime classes. If you put classes on the bootclasspath
they will become system classes and therefore not considered for code
coverage.

For the command line tool please open a feature request. But this will
probably not get top prio.

Best regards,
-marc

judovana

unread,
Nov 27, 2012, 12:43:26 PM11/27/12
to jac...@googlegroups.com
Marc, thank you very much for so much patience with me!

I have posted the  feature  for icedtea-web today - http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2012-November/020984.html and I'm going to fill the feature request for tool together with first code which can be used -

http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20121127/ba8f6a1e/jacoco-tool-0001.diffhttp://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20121127/ba8f6a1e/jacoco-tool-0001.diff

If nothing else one can found this tool as nice example for his future work.

Best regards,
 J.

i.d.rathe...@gmail.com

unread,
Jul 3, 2015, 10:56:44 AM7/3/15
to jac...@googlegroups.com
Hi,

(replying to an old post from 2012)

On Monday, November 19, 2012 at 7:44:35 PM UTC+1, judovana wrote:
> I was used to call commandline application to merge results from integration and unit-tests results, and also for generating individual  and merged (xml+html) results.
>
> I have not found this in jacoco. [...]

I had the same problem, and could not find a solution either.

A few months after the quoted post, JaCoCo has as open pull request for a
CLI tool:

https://github.com/jacoco/jacoco/pull/86

but it is unmerged since ~2 years.

Being in need of a CLI nonetheless, I threw something together at:

https://github.com/quelltextlich/jacoco-toolbox

. The jar allows to access JaCoCo's functionality to

* merge inputs, and
* generate CSV, XML, and HTML reports

directly from the command line.


Maybe it's useful for other people finding this thread in the future.


Have fun,
Christian
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages