@@ -32,14 +32,20 @@ val forkedTestLimit = gradle.sharedServices.registerIfAbsent("forkedTestLimit",
3232 maxParallelUsages.set(3 )
3333}
3434
35+ // Use lazy providers to avoid evaluating the property until it is needed
36+ val skipTestsProvider = rootProject.providers.gradleProperty(" skipTests" )
37+ val skipForkedTestsProvider = rootProject.providers.gradleProperty(" skipForkedTests" )
38+ val skipFlakyTestsProvider = rootProject.providers.gradleProperty(" skipFlakyTests" )
39+ val runFlakyTestsProvider = rootProject.providers.gradleProperty(" runFlakyTests" )
40+
3541// Go through the Test tasks and configure them
3642tasks.withType(Test ::class .java).configureEach {
3743 // Disable all tests if skipTests property was specified
38- onlyIf { ! project.rootProject.hasProperty( " skipTests " ) }
44+ onlyIf { ! skipTestsProvider.isPresent }
3945
4046 // Enable force rerun of tests with -Prerun.tests.${project.name}
4147 outputs.upToDateWhen {
42- ! project. rootProject.hasProperty (" rerun.tests.${project.name} " )
48+ ! rootProject.providers.gradleProperty (" rerun.tests.${project.name} " ).isPresent
4349 }
4450
4551 // Avoid executing classes used to test testing frameworks instrumentation
@@ -68,7 +74,7 @@ tasks.withType(Test::class.java).configureEach {
6874 forkEvery = 1
6975 // Limit the number of concurrent forked tests
7076 usesService(forkedTestLimit)
71- onlyIf { ! project.rootProject.hasProperty( " skipForkedTests " ) }
77+ onlyIf { ! skipForkedTestsProvider.isPresent }
7278 } else {
7379 exclude(" **/*ForkedTest*" )
7480 }
@@ -89,7 +95,7 @@ project.afterEvaluate {
8995 } else if (it.name != " traceAgentTest" ) {
9096 allTestsTask.dependsOn(it)
9197 }
92- // Make check depend on this test task
98+
9399 checkTask.configure {
94100 dependsOn(it)
95101 }
@@ -102,17 +108,17 @@ project.afterEvaluate {
102108 // Flaky tests management for JUnit 5
103109 if (testFramework is JUnitPlatformOptions ) {
104110 val junitPlatform = testFramework as JUnitPlatformOptions
105- if (project.rootProject.hasProperty( " skipFlakyTests " ) ) {
111+ if (skipFlakyTestsProvider.isPresent ) {
106112 junitPlatform.excludeTags(" flaky" )
107- } else if (project.rootProject.hasProperty( " runFlakyTests " ) ) {
113+ } else if (runFlakyTestsProvider.isPresent ) {
108114 junitPlatform.includeTags(" flaky" )
109115 }
110116 }
111117
112118 // Flaky tests management for Spock
113- if (project.rootProject.hasProperty( " skipFlakyTests " ) ) {
119+ if (skipFlakyTestsProvider.isPresent ) {
114120 jvmArgs(" -Drun.flaky.tests=false" )
115- } else if (project.rootProject.hasProperty( " runFlakyTests " ) ) {
121+ } else if (runFlakyTestsProvider.isPresent ) {
116122 jvmArgs(" -Drun.flaky.tests=true" )
117123 }
118124 }
0 commit comments