Skip to content

Commit 08cb139

Browse files
committed
minor refactor: warning for junit.network only when we test
1 parent 17e66a2 commit 08cb139

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

build-logic/src/main/groovy/org.apache.groovy-tested.gradle

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,18 @@ Closure buildExcludeFilter(boolean legacyTestSuite) {
182182
}
183183

184184
// Warn (rather than silently NO-SOURCE) when the groovy/grape exclusion
185-
// swallows the entirety of a project's test source set. A plain
186-
// `:groovy-grape-test:test` invocation otherwise reports BUILD SUCCESSFUL
187-
// with zero tests executed — easy to mistake for a passing run.
188-
afterEvaluate {
189-
if (!providers.systemProperty('junit.network').getOrNull()) {
190-
boolean hasGrapeTests = sourceSets.test.allSource.srcDirs.any {
191-
new File(it, 'groovy/grape').isDirectory()
192-
}
193-
if (hasGrapeTests) {
194-
String testPath = (project.path == ':' ? '' : project.path) + ':test'
195-
logger.warn("WARNING: ${testPath} will skip groovy/grape/* tests; set -Djunit.network=true to include them")
196-
}
185+
// swallows the entirety of a project's test source set.
186+
gradle.taskGraph.whenReady { graph ->
187+
def testTask = tasks.named('test').get()
188+
logger.lifecycle("DEBUG[grape-warn] project=${project.path} hasTest=${graph.hasTask(testTask)}")
189+
if (!graph.hasTask(testTask)) return
190+
if (providers.systemProperty('junit.network').getOrNull()) return
191+
boolean hasGrapeTests = sourceSets.test.allSource.srcDirs.any {
192+
new File(it, 'groovy/grape').isDirectory()
193+
}
194+
logger.lifecycle("DEBUG[grape-warn] project=${project.path} hasGrapeTests=${hasGrapeTests}")
195+
if (hasGrapeTests) {
196+
logger.warn("WARNING: ${testTask.path} will skip groovy/grape/* tests; set -Djunit.network=true to include them")
197197
}
198198
}
199199

0 commit comments

Comments
 (0)