Allow forked test tasks for source sets other than test - #12147
Draft
AlexeyKuznetsov-DD wants to merge 1 commit into
Draft
Allow forked test tasks for source sets other than test#12147AlexeyKuznetsov-DD wants to merge 1 commit into
AlexeyKuznetsov-DD wants to merge 1 commit into
Conversation
Contributor
|
π― Code Coverage (details) π Commit SHA: 36f6dd2 | Docs | Datadog PR Page | Give us feedback! |
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AlexeyKuznetsov-DD
force-pushed
the
alexeyk/forked-test-source-set
branch
from
August 5, 2026 15:13
b5e02c8 to
36f6dd2
Compare
Contributor
π’ Java Benchmark SLOs β All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
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.
What Does This Do
Lets a module register a forked-test task for a source set other than
test.gradle/java_no_deps.gradleregistered a single hardcodedforkedTesttask bound tosourceSets.test. This turns that registration into a reusable helper next to its siblings ingradle/test-suites.gradle, and calls it with'test'from the same place as before:A module with its own suites now opts in with one line:
No behaviour changes for any existing module:
forkedTestis still registered for every project, with the same name and the same configuration.Motivation
Modules that do not use the default
testsource set silently do not run their forked tests.The convention plugin excludes
**/*ForkedTest*from every non-forked Test task, and the only task that runs them was bound tosourceSets.test. A module that keeps its tests in its own suites β for example to compile the same tests against several Scala versions β therefore has no task that runs its*ForkedTestclasses at all.Two modules are in exactly that state today, with forked tests that have never executed:
dd-java-agent/instrumentation/pekko/pekko-http-1.0β 6 classes insrc/baseTestdd-java-agent/instrumentation/netty/netty-3.8β 2 classes insrc/latestDepTestThis PR only provides the mechanism. Switching those modules on is deliberately left out, because their dormant tests do not currently pass β running pekko's surfaces a real NPE in
PekkoHttpClientHelpers$PekkoHttpHeadersduring Data Streams injection β and each needs its own investigation.Additional Notes
No wiring needed for CI.
check,allTestsandallLatestDepTestsselect Test tasks by type rather than by name, so a task registered through the helper is picked up automatically. Thelatestsubstring convention also routeslatestDepTestForkedTesttoallLatestDepTestsandbaseTestForkedTesttoallTestswithout further work.Follow-up refactor available. Around 10 call sites across 8 modules currently use
addTestSuiteExtendingForDir(<name>, <parent>, <parent's own dir>), which creates a second source set that recompiles identical sources with identical dependencies purely to obtain a forked runner. Those collapse to a singleaddForkedTestTask('<parent>')call, removing a duplicate compilation and, in five of them, thecompile<Name>ForkedTestGroovy { classpath += ... }fix-ups that exist only because of the duplicate source set. None of those suites declare their own dependencies, and none of the task names are referenced from CI, so the change is mechanical β but it renames tasks, so it belongs in its own PR. Candidates:akka-actor-2.5,akka-http-10.0,aws-java-sdk-1.11(Γ2),aws-java-sdk-2.2(Γ2),spring-scheduling-3.1,spring-webmvc-3.1,tomcat-5.5,vertx-web-4.0.Why a plain closure and not a default parameter. The helper lives in
test-suites.gradlealongsideaddTestSuite/addTestSuiteForDir/addTestSuiteExtendingForDir. Injava_no_deps.gradlethe Spotless Groovy formatter reformats a typed closure parameter onto its own line, which is why that file uses lambda syntax elsewhere; intest-suites.gradlethe plain closure form is left alone, matching the neighbouring helpers.Validation.
:internal-api:forkedTest(a module using the defaulttestsource set) runs and passes β 6 tests β confirming the default registration is unchanged.addForkedTestTask('baseTest')andaddForkedTestTask('latestDepTest')topekko-http-1.0registeredbaseTestForkedTestandlatestDepTestForkedTestnext to the existingforkedTest; reverted afterwards.Could not find method addForkedTestTask(), confirming the helper is what provides it.spotlessGroovyGradleCheckpasses.Executing forked tests in a module that builds the agent could not be verified locally:
io.sqreen:libsqreen:17.5.0currently returns403 Forbiddenfrom Maven Central on this machine. That reproduces on a clean checkout without this change, so it is unrelated to this PR.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
π€ Generated with Claude Code