manual exclusions

20 views
Skip to first unread message

Aryeh Friedman

unread,
Oct 3, 2024, 3:31:00 AM10/3/24
to jac...@googlegroups.com
I am not using ant/maven or any other supported third party build/test
coverage creation combo (i.e. roll my own) and was wondering how to
get excludes=... really working currently it will exclude the but not
from the HTML coverage report:

#!/bin/tcsh
#
# Copyright (C) 2024 Aryeh M. Friedman
# Copyright (C) 2018-2021 Friedman-Nixon-Wong Enterprises, LLC & contributors

source getVersions.csh

set project=`aesub '$p'`
set tmp=/tmp/$$
set here=`pwd`
set sysLib=/usr/local/share/java/classes;
#sh src/testdata/pt1.sh

sudo rm -rf $here/jacoco.exec
sudo touch $here/jacoco.exec
sudo chmod 777 $here/jacoco.exec

mkdir $tmp
chmod 777 $tmp
cd $tmp

ln -s $here/src src

sudo -u www java
"-javaagent:$sysLib/jacocoagent.jar=destfile=$here/jacoco.exec,jmx=true,excludes=test/**"
-cp $here/scrap/www/WEB-INF/lib/$project.jar:$sysLib/thisTest$thisTestVersion.jar:$sysLib/pcCommon$pcCommonVersion.jar:$sysLib/dudes-lang-common$dudeslangcommonVersion.jar
test.TestMain
set stat=$?

cd $here
sudo rm -rf testCoverage
set cf="";
foreach i (`ls -d scrap/obj/java/21/*`)
if($i == scrap/obj/java/21/mockdata) then
continue;
endif

if($i == scrap/obj/java/21/test) then
continue;
endif

if($i == scrap/obj/java/21/testapps) then
continue;
endif

set cf=`echo '--classfiles'=$i $cf`
end

sudo java -jar $sysLib/jacococli.jar report jacoco.exec $cf
--sourcefiles=src/java --html=testCoverage --quiet
sudo chmod -R 777 testCoverage

sudo rm -rf $tmp
exit $stat


--
Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org

Marc Hoffmann

unread,
Oct 3, 2024, 3:22:18 PM10/3/24
to JaCoCo and EclEmma Users
Hi,

please see FAQ (https://www.jacoco.org/jacoco/trunk/doc/faq.html):

Regards,
-marc


Why do I see classes in the coverage report although I excluded them in the JaCoCo agent configuration?

The includes and excludes options of the JaCoCo agent determine for which classes execution data is collected. Except for technical corner cases these options are normally not required. If you exclude classes, no execution data is collected for them.

Report creation is a separate step where all class files which should show up in the report are explicitly provided. Coverage is determined from the provided execution data. If execution data is missing for a particular class, this class is shown as not covered because the report generator cannot distinguish whether the class was excluded from instrumentation or not executed.

If you want to exclude classes from the report please configure the respective report generation tool accordingly. 




--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAGBxaXmu0%2BJfvU%2BQL4VxKzJ5jbsCoWaW5ozSDL0Ku0gRTdO01w%40mail.gmail.com.

Aryeh Friedman

unread,
Oct 3, 2024, 5:00:08 PM10/3/24
to jac...@googlegroups.com
On Thu, Oct 3, 2024 at 3:22 PM Marc Hoffmann <hoff...@mountainminds.com> wrote:

> If you want to exclude classes from the report please configure the respective report generation tool accordingly.

Note the purpose of my project is to validate the code used in
theoretical CS research/experiments and thus for the experiments to be
valid the code needs to be trustworthy and 100% coverage is the
starting and not the ending point of this process.

Like I said the only report generating tools I have are what came with
jacoco... does this mean I have to generate CSV and finely comb it for
details when all I want is a report that says I get 100% coverage for
all non-excluded classes and methods when in fact I have 100%
coverage. Also if I understand right the above would mean that I
can't even get 100% coverage on a class that has an excluded method.
Also how do I exclude specific statements/brances such as the one this
comment relates to:

public Chunk consumeWhile(Class<?> klass)
{
SimpleChunkBuilder builder=new SimpleChunkBuilder();

// due the fact that all tape movements are managed
// by us it is impossible to contrive a trivial case
// where the false condition is covered in testing
// and the tape is completely encapsulated
// therefore Jacoco will always report a missed branch
while(pos<body.size()) {
Parseable p=peek();

if(!klass.isInstance(p))
break;

builder.add(consume());
}

return builder.toChunk();
}

Namely due to how the class is built the following will never be true
pos>=body.size() but we still need the guard condition because there
are always odd balls. So for example the coverage report for the
project says I have 100% statement coverage and 99% (1 branch missed
in 192 branches) and the offender being the above. Due to the
criticality of the app we have an iron clad rule tha all production
code needs 100% coverage of lines and branches unless there is a
comment explaining why that is not possible.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/9C683BF3-9670-40CB-9C7C-57D037654883%40mountainminds.com.
Reply all
Reply to author
Forward
0 new messages