Repository navigation
Remove the test suites' isolation settings that test-config.gradle overrides - #16839
Conversation
…errides test-config.gradle configures every Test task after the build script that applies it, and it assigned its excludes, so the excludes a suite had set were replaced. Since 2025-03-30 the classes grails-test-suite-web isolates have run in its test task as well as in execIsolatedTests, which has run with the shared forkEvery rather than 1 since 2025-04-18; they pass in the shared JVMs, so the task, its list and the combined report go. The classes grails-test-suite-persistence excludes and isolates no longer exist and its two isolated tasks ran nothing; its forkEvery and local heap were overridden as well. grails-test-suite-uber isolated a spec that has since moved to grails-core. test-config.gradle now adds its excludes to those of the module.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16839 +/- ##
==============================
==============================
🚀 New features to boost your workflow:
|
sbglasius
left a comment
There was a problem hiding this comment.
This an AI assisted review
LGTM. I checked the ordering argument and it holds in both modules:
- web: the
tasks.named('test').configure { … }action was registered beforeapply from: test-config.gradle. Lazy configure actions run in registration order, so the laterconfigureEachreplacedexcludesand overrodeforkEvery.execIsolatedTeststherefore ran classes thattestalso ran. - persistence:
test { … }realized the task eagerly, and then theconfigureEachthatapplyregistered ran immediately on it. That overrodeforkEvery,maxHeapSizeandexcludes. The three excluded classes don't exist anywhere in the tree, andtestGrailsDomainBinder/testIsolatedPersistentOnehad notestClassesDirs, so they were NO-SOURCE. - uber:
DefaultGrailsControllerClassSpecnow lives only ingrails-core/src/test, so the pattern matched nothing. - No remaining references to
execIsolatedTests,createCombinedReport,testGrailsDomainBinder,testIsolatedPersistentOneorreports/allTestsanywhere in the repo, including workflows.
Changing excludes = [...] to exclude(...) is a sensible safeguard, and CI is green.
Two non-blocking nits:
gradle/test-config.gradle: the new comment covers excludes only. The same trap is still there forforkEvery,maxParallelForksandmaxHeapSize: a module that sets them before applying the script loses them without any warning, which is how this cleanup became necessary. It could help to say so next to the comment, for example "settings other than excludes must be configured after applying this script". The uber build already has a comment like that.grails-test-report/build.gradle: the comment aboveisolatedUnitTestPhasesstill says "the test-suite projects also run some classes in their own Test tasks". Onlygrails-test-suite-uberdoes that now, so you could name it there.
test-config.gradle sets maxParallelForks, maxHeapSize and forkEvery over the values a module set before applying it, so a module that needs its own values sets them after applying it. Only grails-test-suite-uber still runs classes in Test tasks of its own, so grails-test-report names it.
🔎 No tests executed 🔎🏷️ Commit: 4a160f8 Learn more about TestLens at testlens.app/docs. |
|
Thanks for checking the ordering, @sbglasius. Both nits are addressed in 4a160f8:
The commit changes only comments, so I pushed it without a CI run. |
sbglasius
left a comment
There was a problem hiding this comment.
This an AI assisted review
I found no blocking issues. The analysis in the description checks out against the tree at 4a160f8.
What I checked
exclude(...)instead ofexcludes = [...]ingradle/test-config.gradle. The only build scripts that set Test excludes orforkEveryand also applytest-config.gradlewere the web and persistence suites, and this PR removes both. The other modules that set their own values either apply a different config script (grails-data-neo4j/core,grails-test-examples/context-hierarchy, the hibernatedbmigrationmodules, where theexcludeis onjaranyway) or set them after the configure action (grails-test-suite-uber, which doesn't applytest-config.gradle). Switching toexclude(...)doesn't change any remaining task's effective excludes.- Web isolated list. 9 of the 12 patterns match a class that still exists in
grails-test-suite-web.JSONBindingToNullTestsis declared inJSONBindingToNullSpec.groovy, which is why a filename search misses it.GroovyPageAttributesTestsis now ingrails-gsp/grails-taglib, andGSPResponseWriterSpecand thepages/ext/jspclasses are gone, so those 3 match nothing. This agrees with the description, and those 9 classes have already been running in the sharedtestforks, so droppingexecIsolatedTestsdoesn't change where any test runs. - Persistence.
GrailsDomainBinderTests,ComponentValidationTestsandHibernateMappingUniqueConstraintTestsno longer exist anywhere in the repo. The two registered tasks had notestClassesDirs, so they were NO-SOURCE, as the description says. - Uber.
DefaultGrailsControllerClassSpecis now ingrails-core/src/test/groovy/org/grails/core/, so theisolatedTestsOneentry was dead. - Leftover references. Nothing else in the repo, including the workflows and
grails-test-report, refers toexecIsolatedTests,createCombinedReport,testGrailsDomainBinder,testIsolatedPersistentOneorreports/allTests.
Minor / optional
- The new comment in
test-config.gradle("A module that needs its own values sets them after applying it") is the important guidance here. It could also say that "after" means a configure action registered later, such astasks.named('test') { ... }placed below theapplyblock. Otherwise someone might think atest { }block placed beforeapplywould still win. It doesn't, because theconfigureEachaction runs after it in either case. build-logic/docs-core/build.gradle:139still uses theexcludes = [...]assignment. It's a separate build and nothing is applied before it, so nothing is broken there. It's only mentioned here for consistency, if you want the two to match.- If one of the formerly isolated web classes starts polluting static state again, there's no isolation mechanism left in
grails-test-suite-web. The uber pattern (afilter.includePatternstask registered aftertest-config.gradle) would be the way to add one back. That's fine for now given these classes have run in shared forks since early 2025.
LGTM from my side.
Description
gradle/test-config.gradleconfigures everyTesttask in aconfigureEachthat runs after the build script that applies it, and it assignedexcludes, so the settings the test suites made before applying it were replaced or overridden. This removes the settings that had stopped doing anything, and the isolation that had stopped isolating.grails-test-suite-web:testexcluded 12 class patterns so thatexecIsolatedTestscould run them withforkEvery = 1. Theexcludesassignment oftest-config.gradle(since 26d5c0e, 2025-03-30) replaced the exclusion, so the 9 of those classes that still exist (52 tests) ran intestas well as inexecIsolatedTests, and the sharedforkEveryhas overridden the 1 since a58aa14 (2025-04-18). They have run in the shared JVMs oftestsince then and pass there, soexecIsolatedTests, its list,createCombinedReport, and theforkEvery,maxParallelForksandexcludesthattest-config.gradlesets anyway go. Three of the patterns matched nothing:GroovyPageAttributesTestsis ingrails-gsp/grails-taglibnow, andGSPResponseWriterSpecandpages/ext/jspare gone.grails-test-suite-persistence: the three classes it excluded fromtestand isolated (GrailsDomainBinderTests,ComponentValidationTests,HibernateMappingUniqueConstraintTests) no longer exist, and itstestGrailsDomainBinderandtestIsolatedPersistentOnetasks were NO-SOURCE, as aTesttask registered withouttestClassesDirsis. ItsforkEvery = 25and local 2 GB heap were overridden. All of it goes.grails-test-suite-uber:isolatedTestsOnenamedDefaultGrailsControllerClassSpec, which is ingrails-corenow. Uber filters its isolated classes by name and does not applytest-config.gradle, so its other isolated tasks work as they should.grails-test-report:execIsolatedTestsleaves its list of isolated phases.gradle/test-config.gradleadds its excludes withexclude(...)rather than assigning them, so the excludes a module sets before applying it survive.Verification
Testtask in the build (forkEvery,maxParallelForks, heap, excludes, includes and filters), printed before and after the change, differ only in the removed tasks and the removed uber pattern. No other module's excludes were being replaced, so theexclude(...)change leaves every remaining task as it was.:grails-test-suite-web:check,:grails-test-suite-persistence:checkand:grails-test-suite-uber:checkpass: web 84 classes and 490 tests, persistence 13 and 114, uber'stest122 and 624 and its five isolated tasks 10 and 42.test-config.gradlehas every test print. It runs 52 fewer test executions, and those are the second runs of the 9 web classes../gradlew clean aggregateViolations --continuepasses.#16837 also changes
gradle/test-config.gradleandgrails-test-suite-uber/build.gradle, on other lines.