TS-47712 Record the coverage of the JVMs our tests spawn - #966
Merged
Conversation
DreierF
force-pushed
the
ts/47712_spawned_jvm_coverage
branch
from
September 3, 2026 06:04
1374bb1 to
cba6b68
Compare
Most of what this repository ships is executed during the build, but not in a JVM that anyone instruments, so Teamscale reports it as untested. The Mojos of the Maven plugin, the report generator they call into and the whole Gradle plugin run in the Maven and Gradle builds that the system tests and the TestKit tests start as child processes. The JaCoCo agent that com.teamscale.coverage attaches reaches only the test JVM itself, which does little more than run a mock Teamscale server: the jacocoTestReport.xml of every system test was an empty stub, because a system test has no production code of its own to fill the report's class directories with either. The new com.teamscale.spawned-jvm-coverage convention plugin attaches a plain JaCoCo agent to those child processes and folds what it records into the project's jacocoTestReport, which is the report CI uploads. It also lets the consuming build script name the projects whose classes run in there, so that the report can be mapped onto their sources; they are resolved through a configuration rather than read from the projects, which is what keeps this compatible with project isolation. The agent reaches Maven through MAVEN_OPTS, whose JVM is the one the Mojos run in, and Gradle through org.gradle.jvmargs, since its build logic runs in the daemon rather than in the launcher that GRADLE_OPTS would reach. JAVA_TOOL_OPTIONS would have covered both plus the forked test JVMs, but it announces itself on the stderr of every JVM, which sut-uses-logback-test asserts is empty, and it would put a second agent into the JVMs that the profiler already instruments. The include pattern deliberately does not match the shadow.com.teamscale.* classes of the profiler, which AgentOptions.DEFAULT_EXCLUDES keeps the profiler itself from instrumenting, so the two agents record a disjoint set of classes and cannot interfere with each other. Coverage of the classes involved, as Teamscale sees it across all uploaded reports: the Gradle plugin's own report goes from 2 of 284 methods to 188, the Maven plugin from 6 of 102 to 81, the report generator from 182 of 284 to 235 and the client from 54 of 198 to 96. Branch and pull request builds now upload their coverage as well. They ran every test but uploaded nothing, so until a change reached master all of its methods looked untested. On a pull request the checkout is the synthetic merge commit, which does not exist in the repository, so the head commit is named explicitly rather than left to the commit auto detection. Builds of pull requests from forks are still skipped, since they get no secrets. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
DreierF
force-pushed
the
ts/47712_spawned_jvm_coverage
branch
from
September 3, 2026 06:21
cba6b68 to
aa61182
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses issue TS-47712
Please respect the vote of the Teamscale bot or flag irrelevant findings as tolerated or false positives. If you feel that the Teamscale config needs adjustment, please state so in a comment and discuss this with your reviewer.