Restrict JaCoCo instrumentation to Spock packages#2374
Conversation
Configure both the JaCoCo Gradle plugin's Test task agent and the custom compile-time agent to only instrument spock.* and org.spockframework.* classes, rather than instrumenting all classes loaded under test.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughJaCoCo instrumentation is expanded to cover both ChangesJaCoCo Instrumentation Scope
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR restricts JaCoCo instrumentation to Spock's own class packages (
Confidence Score: 5/5Both changes are narrow build-logic adjustments with no impact on production or test runtime behavior, only on which classes JaCoCo instruments. The two changed files are isolated to build configuration. The JaCoCo Gradle plugin is always applied before the new configureEach block executes, so getByType(JacocoTaskExtension) will never throw. The wildcard patterns correctly cover all multi-level subpackages because JaCoCo's * wildcard matches across . separators, consistent with the pre-existing org.spockframework.* usage. The agent string and Gradle extension are now consistent with each other. No logic paths are affected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SpockBasePlugin.apply] --> B[applyPlugins\nApplies 'jacoco' Gradle plugin]
B --> C[compileTasks]
C --> D[jarTasks]
D --> E[testTasks\nwithType Test .configureEach\nreports, timeout, SpockConfig]
E --> F[jacoco\nSets toolVersion\nwithType Test .configureEach]
F --> G{JacocoTaskExtension\nalready registered\nby Gradle JaCoCo plugin?}
G -- Yes --> H[Set includes =\n'spock.*','org.spockframework.*']
G -- No --> I[RuntimeException]
J[compileTestGroovy task] --> K[JacocoJavaagentProvider.asArguments]
K --> L['-javaagent:...includes=\norg.spockframework.*:spock.*']
Reviews (1): Last reviewed commit: "Restrict JaCoCo instrumentation to Spock..." | Re-trigger Greptile |
✅ All tests passed ✅🏷️ Commit: fd4fd4c Learn more about TestLens at testlens.app. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2374 +/- ##
=========================================
Coverage 82.33% 82.33%
Complexity 4877 4877
=========================================
Files 474 474
Lines 15205 15205
Branches 1935 1935
=========================================
Hits 12519 12519
Misses 1993 1993
Partials 693 693 🚀 New features to boost your workflow:
|
What
Configure JaCoCo to only instrument Spock's own packages (
spock.*andorg.spockframework.*) instead of instrumenting every class loaded under test.Why
The JaCoCo agent was instrumenting all loaded classes, including the third-party libraries exercised by the specs. Restricting instrumentation to Spock's packages keeps coverage data focused on the code we actually own and reduces instrumentation overhead.
Changes
SpockBasePlugin: thejacocoGradle plugin'sJacocoTaskExtensionhad no include filter, so everyTesttask instrumented everything. Setincludes = ['spock.*', 'org.spockframework.*']on allTesttasks.JacocoJavaagentProvider: the custom agent used for thecompileTestGroovyAST-dump coverage already filtered toorg.spockframework.*; added the missingspock.*(the agent'sincludesoption is colon-separated).