You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "jamesfredley (via GitHub)" <gi...@apache.org> on 2026/07/17 21:52:40 UTC
[PR] Characterize plugin registry load order and lookup contract [grails-core]
jamesfredley opened a new pull request, #16004:
URL: https://github.com/apache/grails-core/pull/16004
## Summary
- add a test-only characterization spec that pins the public plugin-registry contract a future load/registry optimization must preserve
- asserts the two DISTINCT public observables separately: the actual load sequence consumed by `loadPlugins()` / `getPluginsInLoadOrder()` and the `getAllPlugins()` topological order
- covers repeated-build determinism, duplicate-registration dedup, and name/class-name/version lookup identity (each resolves the same non-null tail instance)
## Scope note
Test-only; no production changes. Exercises only public `GrailsPluginManager` APIs and deliberately does not duplicate the existing `GrailsPluginSorterSpec` sorter coverage - it characterizes end-to-end manager registry output instead.
## Verification
- :grails-core:test --tests DefaultGrailsPluginManagerRegistryContractSpec
- :grails-core:test
- git diff --check
This is an AI-generated starting point pinning the plugin-registry/load-order contract.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Characterize plugin registry load order and lookup contract [grails-core]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #16004:
URL: https://github.com/apache/grails-core/pull/16004#discussion_r3606384990
##########
grails-core/src/test/groovy/grails/plugins/DefaultGrailsPluginManagerRegistryContractSpec.groovy:
##########
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package grails.plugins
+
+import grails.core.DefaultGrailsApplication
+import org.apache.grails.core.plugins.DefaultPluginDiscovery
+import org.springframework.core.env.StandardEnvironment
+import spock.lang.Specification
+
+class DefaultGrailsPluginManagerRegistryContractSpec extends Specification {
+
+ void 'the discovery load order consumed by the manager is deterministic for a combined ordering graph'() {
+ given:
+ def pluginClasses = orderingPluginClasses()
+ def expectedLoadOrder = [
+ 'registryOrderingRoot',
+ 'registryOrderingBefore',
+ 'registryOrderingRight',
+ 'registryOrderingLeft',
+ 'registryOrderingJoin',
+ 'registryOrderingTail'
+ ]
+
+ when:
+ def loadOrders = (1..3).collect {
+ def discovery = createDiscovery(pluginClasses)
+ createManager(discovery)
+ discovery.getPluginsInLoadOrder()*.name
+ }
+
+ then:
+ loadOrders == [expectedLoadOrder, expectedLoadOrder, expectedLoadOrder]
+ }
+
+ void 'the loaded registry exposes a deterministic topological order for a combined ordering graph'() {
+ given:
+ def pluginClasses = orderingPluginClasses()
+ def expectedTopologicalOrder = [
+ 'registryOrderingBefore',
+ 'registryOrderingRoot',
+ 'registryOrderingRight',
+ 'registryOrderingLeft',
+ 'registryOrderingJoin',
+ 'registryOrderingTail'
+ ]
+
+ when:
+ def topologicalOrders = (1..3).collect {
+ def discovery = createDiscovery(pluginClasses)
+ createManager(discovery).getAllPlugins()*.name
+ }
+
+ then:
+ topologicalOrders == [expectedTopologicalOrder, expectedTopologicalOrder, expectedTopologicalOrder]
+ }
+
+ void 'the loaded registry de-duplicates plugins and resolves each plugin consistently'() {
+ given:
+ def pluginClasses = orderingPluginClasses()
+ def tailPluginClass = pluginClasses.find { it.name == 'RegistryOrderingTailGrailsPlugin' }
+ def discovery = createDiscovery(pluginClasses + tailPluginClass)
+ def manager = createManager(discovery)
+
+ when:
+ def tailPlugins = manager.getAllPlugins().findAll { it.name == 'registryOrderingTail' }
+ def expectedTailPlugin = tailPlugins.first()
+ def pluginByName = manager.getGrailsPlugin('registryOrderingTail')
Review Comment:
`tailPlugins.first()` will throw `NoSuchElementException` when the list is empty, which can mask the real assertion failure you want (dedup/lookup contract) and produce a less-informative test failure. Make the selection safe so the `then:` block drives the failure reporting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Characterize plugin registry load order and lookup contract [grails-core]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #16004:
URL: https://github.com/apache/grails-core/pull/16004#issuecomment-5008009936
## [Codecov](https://app.codecov.io/gh/apache/grails-core/pull/16004?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 51.1200%. Comparing base ([`0c63c26`](https://app.codecov.io/gh/apache/grails-core/commit/0c63c26a3ab850f5f678ad0fcc934d8d59096c03?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`44d5cfa`](https://app.codecov.io/gh/apache/grails-core/commit/44d5cfafe0d6e9d5cb6cf9e56e09011622aa94cb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/grails-core/pull/16004?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## 8.0.x #16004 +/- ##
==================================================
+ Coverage 51.1168% 51.1200% +0.0031%
- Complexity 17597 17601 +4
==================================================
Files 2041 2041
Lines 95493 95493
Branches 16587 16587
==================================================
+ Hits 48813 48816 +3
+ Misses 39394 39391 -3
Partials 7286 7286
```
[see 3 files with indirect coverage changes](https://app.codecov.io/gh/apache/grails-core/pull/16004/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Characterize plugin registry load order and lookup contract [grails-core]
Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #16004:
URL: https://github.com/apache/grails-core/pull/16004#issuecomment-5008277942
## ✅ All tests passed ✅
🏷️ Commit: 44d5cfafe0d6e9d5cb6cf9e56e09011622aa94cb
▶️ Tests: 18994 executed
⚪️ Checks: 61/61 completed
---
_Learn more about TestLens at [testlens.app](https://testlens.app)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Characterize plugin registry load order and lookup contract [grails-core]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #16004:
URL: https://github.com/apache/grails-core/pull/16004#issuecomment-5007832797
<!-- Bito Reply -->
To make the selection safe and avoid `NoSuchElementException` when the list is empty, you can use `.find()` or `.first()` with a default value, or check the size before accessing. Given the context of the test, using `find { true }` or checking the list size is appropriate to ensure the `then:` block handles the failure reporting correctly.
Here is the suggested update for the test:
```groovy
when:
def tailPlugins = manager.getAllPlugins().findAll { it.name == 'registryOrderingTail' }
def expectedTailPlugin = tailPlugins ? tailPlugins.first() : null
def pluginByName = manager.getGrailsPlugin('registryOrderingTail')
```
This change ensures that `expectedTailPlugin` is `null` if the list is empty, allowing the subsequent assertions in the `then:` block to fail gracefully with descriptive messages rather than throwing an exception.
**grails-core/src/test/groovy/grails/plugins/DefaultGrailsPluginManagerRegistryContractSpec.groovy**
```
when:
def tailPlugins = manager.getAllPlugins().findAll { it.name == 'registryOrderingTail' }
def expectedTailPlugin = tailPlugins ? tailPlugins.first() : null
def pluginByName = manager.getGrailsPlugin('registryOrderingTail')
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Characterize plugin registry load order and lookup contract [grails-core]
Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley merged PR #16004:
URL: https://github.com/apache/grails-core/pull/16004
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org