This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch matrei/uber-tests-build
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 8959380ab8b616c7fca69a972a14e580aa9fd0a2
Author: Mattias Reichel <[email protected]>
AuthorDate: Thu Mar 19 15:40:16 2026 +0100

    build: enable running single tests with --tests flag
    
    And some cleanup.
---
 grails-test-suite-uber/build.gradle | 83 ++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 52 deletions(-)

diff --git a/grails-test-suite-uber/build.gradle 
b/grails-test-suite-uber/build.gradle
index f92621756c..aa7b5efeb8 100644
--- a/grails-test-suite-uber/build.gradle
+++ b/grails-test-suite-uber/build.gradle
@@ -80,73 +80,58 @@ dependencies {
     testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
     testRuntimeOnly 'org.springframework:spring-aspects'
 
-
     // Testing
     testImplementation('org.spockframework:spock-core') { transitive = false }
+
     // Required by Spock's Mocking
     testRuntimeOnly 'net.bytebuddy:byte-buddy'
 }
 
 def isolatedTestPatterns = [
-        isolatedTestsOne              : [
+        isolatedTestsOne: [
                 'org.grails.core.DefaultGrailsControllerClassSpec',
                 'org.grails.web.util.WebUtilsTests'
         ],
-        isolatedTestsTwo              : [
+        isolatedTestsTwo: [
                 'grails.test.mixin.UrlMappingsTestMixinTests',
                 'grails.test.mixin.SetupTeardownInvokeTests',
                 'grails.test.mixin.TestMixinSetupTeardownInvokeTests'
         ],
-        isolatedRestRendererTests     : [
+        isolatedRestRendererTests: [
                 '*.rest.render.*Spec'
         ],
-        isolatedPersonTests           : [
+        isolatedPersonTests: [
                 'org.grails.validation.TestingValidationSpec',
                 'org.grails.validation.CascadingErrorCountSpec'
         ],
         isolatedRestfulControllerTests: [
                 'grails.test.mixin.RestfulControllerSpec',
                 'grails.test.mixin.ResourceAnnotationRestfulControllerSpec'
-        ]
+        ],
+]
+
+def testSkippingProperties = [
+        'onlyFunctionalTests',
+        'onlyHibernate5Tests',
+        'onlyMongodbTests',
+        'skipCoreTests',
+        'skipTests',
 ]
 
 isolatedTestPatterns.keySet().each { taskName ->
-    tasks.register(taskName, Test).configure { Test tTask ->
-        tTask.onlyIf {
-            ![
-                    'onlyFunctionalTests',
-                    'onlyHibernate5Tests',
-                    'onlyMongodbTests',
-                    'skipCoreTests',
-                    'skipTests'
-            ].find {
-                project.hasProperty(it)
-            }
-        }
-        tTask.group = 'verification'
-        tTask.filter.includePatterns = isolatedTestPatterns[taskName]
+    tasks.register(taskName, Test) {
+        group = 'verification'
+        filter.includePatterns = isolatedTestPatterns[taskName]
     }
 }
 
-tasks.named('isolatedTestsTwo', Test).configure {
+tasks.named('isolatedTestsTwo', Test) {
     maxParallelForks = 1
     forkEvery = 100
 }
 
 tasks.withType(Test).configureEach {
-    onlyIf {
-        ![
-                'onlyHibernate5Tests',
-                'onlyMongodbTests',
-                'skipCoreTests'
-        ].find {
-            project.hasProperty(it)
-        }
-    }
-
-    onlyIf {
-        !project.hasProperty('onlyFunctionalTests')
-    }
+    onlyIf { !testSkippingProperties.any {project.hasProperty(it) } }
     useJUnitPlatform()
     maxParallelForks = configuredTestParallel
     forkEvery = isCiBuild ? 50 : 100
@@ -154,25 +139,19 @@ tasks.withType(Test).configureEach {
     jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED', 
'--add-opens=java.base/java.util=ALL-UNNAMED')
 }
 
-tasks.named('test', Test).configure {
-    onlyIf {
-        ![
-                'onlyFunctionalTests',
-                'onlyHibernate5Tests',
-                'onlyMongodbTests',
-                'skipCoreTests',
-                'skipTests'
-        ].find {
-            project.hasProperty(it)
-        }
-    }
-
+tasks.named('test', Test) {
+    // Exclude the isolated tests from the main test task
     filter.excludePatterns = isolatedTestPatterns.values().flatten()
-    dependsOn(provider {
-        tasks.findAll({
-            isolatedTestPatterns.containsKey(it.name)
-        })
-    })
+}
+
+tasks.register('testAll') {
+    group = 'verification'
+    description = 'Runs all tests, including isolated ones.'
+    dependsOn(tasks.withType(Test))
+}
+
+tasks.named('check') {
+    dependsOn('testAll')
 }
 
 tasks.withType(Groovydoc).configureEach {

Reply via email to