curved-vase-73456
12/28/2018, 3:44 AMpants
.
Details
- unit and integration tests are collecting coverage via ./pants test
with --test-junit-coverage-processor=jacoco --test-junit-coverage
options
- for blackbox I couldn’t figure out how to use pants natively, so it’s done using JaCoCo
agent to create foo.exec
and bar.exec
files with java -javaagent:jacocoagent.jar -jar dist/<path to foo.jar>
for bundles that are created by ./pants bundle
and then combined report can be generated via java -jar jacococli.jar report foo.exec bar.exec --classfiles dist/bar.jar --classfiles dist/baz.jar --html <dir to output report to>
Questions
- Is there a way to run bundles using pants and collect coverage data and merge reports for multiple different bundles?
- if not, where one can find classfiles that pants
is using to produce report so that one can specify them when creating a combined report? jacoco.exec
can be found in .pants.d/junit/_runs/..
folder but I don’t see any classfiles there, tmp*.jar
don’t seem to contain the info needed as well, and .pants.d/compile folder contains too many classes I don’t care about and even with filters it seems like some deduplication might be neededaloof-angle-91616
12/28/2018, 3:51 AM.pants.d/
(which is maybe 1/4 of an answer to your first question)curved-vase-73456
12/28/2018, 3:54 AMjava -jar jacococli.jar merge foo.exec bar.exec
creates merged .exec
file, after that report can be generated using java -jar jacococli.jar report combined.exec --classfile <list of classfiles>
or just java -jar jacococli.jar report foo.exec bar.exec --classfiles dist/bar.jar --classfiles dist/baz.jar --html <dir to output report to>
the trouble I have is getting classfiles for unit and integration testscurved-vase-73456
12/28/2018, 3:57 AMaloof-angle-91616
12/28/2018, 4:05 AM./pants bundle
will typically (should) write their result to the 'deployable_archives'
product. src/python/pants/backend/jvm/tasks/bundle_create.py
. it uses the older ProductMapping
api, which essentially is a two-level map from (target -> base dir) -> [list of objects]
. you can consume that product by using round_manager.require('deployable_archives')
in a prepare()
classmethod override, then getting the product mapping from self.context.products.get('deployable_archives')
(which gives you a ProductMapping. there are some examples in the repo of how to use the ProductMapping API, but the class is also pretty well-documented in the repo source. you would probably want to then get your target set with self.context.targets(...)
and with self.invalidated(...)
to get invalid targets, and then you can run jacoco on each of these in turn, and then merging them, by using the jvm tool api, which i'm assuming you're already using.aloof-angle-91616
12/28/2018, 4:07 AMwith self.invalidated(...) as invalidation_check:
invalid_versioned_targets = invalidation_check.invalid_vts # list of VersionedTarget
for vt in invalid_versioned_targets:
vt.target # the target
vt.results_dir # where you would put the output of your task for that target -- VersionedTargetSet also lets you generate a `results_dir` for a list of targets (which you would use for the merge step
cuddly-architect-27013
12/28/2018, 5:06 AMcurved-vase-73456
12/28/2018, 5:21 AMpants
built-in commands to make offline/on-the-fly instrumentation like javaagent
does and produce coverage reports for it. Is there an option to run instrumented jar bundles using pants instead of doing java -javaagent:jacocoagent.jar=includes=<pattern> -jar foo.jar
?
let me know if it makes sense 😅cuddly-architect-27013
12/28/2018, 5:32 AMcuddly-architect-27013
12/28/2018, 5:32 AMcurved-vase-73456
12/28/2018, 5:34 AMcuddly-architect-27013
12/28/2018, 5:34 AMcuddly-architect-27013
12/28/2018, 5:35 AMcuddly-architect-27013
12/28/2018, 5:36 AMaloof-angle-91616
12/28/2018, 5:37 AM./pants bundle
for no reasoncuddly-architect-27013
12/28/2018, 5:37 AMcurved-vase-73456
12/28/2018, 5:37 AM./pants bundle
to make executable jars for bunch of servicescuddly-architect-27013
12/28/2018, 5:37 AMaloof-angle-91616
12/28/2018, 5:39 AM'deployable_archives'
product definitely works for that just would require a separate pants taskcurved-vase-73456
12/28/2018, 5:41 AMcuddly-architect-27013
12/28/2018, 5:42 AMcuddly-architect-27013
12/28/2018, 5:44 AMcuddly-architect-27013
12/28/2018, 5:45 AMcuddly-architect-27013
12/28/2018, 5:45 AMcurved-vase-73456
12/28/2018, 5:48 AMscoverage
scalac plugin to use with pants for similar stuff? JaCoCo is pretty good but it has some caveats that scoverage does better for scala codecuddly-architect-27013
12/28/2018, 5:49 AMcurved-vase-73456
12/28/2018, 5:49 AMcuddly-architect-27013
12/28/2018, 5:49 AMcuddly-architect-27013
12/28/2018, 5:49 AMcuddly-architect-27013
12/28/2018, 5:50 AMcuddly-architect-27013
12/28/2018, 5:50 AMcuddly-architect-27013
12/28/2018, 5:51 AMcurved-vase-73456
12/28/2018, 5:52 AMscoverage
path but already got pretty far on current one to change gears, not enough sprint time 😅cuddly-architect-27013
12/28/2018, 5:54 AMcuddly-architect-27013
12/28/2018, 5:54 AMcurved-vase-73456
12/28/2018, 5:55 AMcurved-vase-73456
12/28/2018, 5:56 AM