Characterize plugin registry load order and lookup contract - #16004
Conversation
Assisted-by: opencode:gpt-5.6-sol
There was a problem hiding this comment.
Pull request overview
Adds a new characterization-style Spock spec to pin down the publicly observable GrailsPluginManager registry behavior around plugin load order vs topological order, including determinism across repeated builds, deduplication, and consistent lookup identity across name/class-name/version APIs. This helps protect expected behavior ahead of future plugin discovery/registry optimizations.
Changes:
- Introduces
DefaultGrailsPluginManagerRegistryContractSpecto assert deterministic plugin discovery load order and deterministic topological registry order for the same dependency graph. - Adds coverage for duplicate-registration deduplication and consistent lookup resolution (
getGrailsPlugin,getGrailsPluginForClassName, versioned lookup) returning the same instance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def tailPlugins = manager.getAllPlugins().findAll { it.name == 'registryOrderingTail' } | ||
| def expectedTailPlugin = tailPlugins.first() | ||
| def pluginByName = manager.getGrailsPlugin('registryOrderingTail') |
|
To make the selection safe and avoid Here is the suggested update for the test: when:
def tailPlugins = manager.getAllPlugins().findAll { it.name == 'registryOrderingTail' }
def expectedTailPlugin = tailPlugins ? tailPlugins.first() : null
def pluginByName = manager.getGrailsPlugin('registryOrderingTail')This change ensures that grails-core/src/test/groovy/grails/plugins/DefaultGrailsPluginManagerRegistryContractSpec.groovy |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #16004 +/- ##
==================================================
+ Coverage 51.1168% 51.4649% +0.3480%
- Complexity 17597 17753 +156
==================================================
Files 2041 2039 -2
Lines 95493 95537 +44
Branches 16587 16571 -16
==================================================
+ Hits 48813 49168 +355
+ Misses 39394 39065 -329
- Partials 7286 7304 +18 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Avoid tailPlugins.first(), which throws on an empty list and can mask Spock then-block failures. Prefer Groovy find (null when missing) and count for the dedup assertion, matching nearby plugin-spec style. Assisted-by: Sisyphus:xai/grok-4.5
Summary
loadPlugins()/getPluginsInLoadOrder()and thegetAllPlugins()topological orderScope note
Test-only; no production changes. Exercises only public
GrailsPluginManagerAPIs and deliberately does not duplicate the existingGrailsPluginSorterSpecsorter coverage - it characterizes end-to-end manager registry output instead.Verification
This is an AI-generated starting point pinning the plugin-registry/load-order contract.