Skip to content

Commit 7896ef8

Browse files
committed
fix(grails-gradle): skip missing input dirs in mergeTestReports
The TestReport task registered by TestPhasesGradlePlugin reads test results from 'test-results/<phase>/binary' directories. When a phase is skipped (e.g. integrationTest under -PonlyCoreTests) the directory does not exist and the TestReport task fails with 'Could not write test report for results in [...]'. Filter testResults with { File f -> f.exists() } so non-existent directories are silently dropped. When nothing is produced for a phase, the merge report is just smaller; when all phases skip, the merge report is empty but the task still succeeds. Fixes 14 cascade failures in grails-test-examples-* modules when the build is invoked with -PonlyCoreTests (the flag used by the CI 'Build Grails-Core' job).
1 parent 28dd32f commit 7896ef8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/TestPhasesGradlePlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ class TestPhasesGradlePlugin implements Plugin<Project> {
142142
it.mustRunAfter(project.tasks.withType(Test).toArray())
143143
it.destinationDirectory.set(project.layout.buildDirectory.dir('reports/tests'))
144144
it.testResults.from(
145-
project.files(project.layout.buildDirectory.dir('test-results/test/binary'))
145+
project.files(project.layout.buildDirectory.dir('test-results/test/binary')).filter { File f -> f.exists() }
146146
)
147147
}
148148
}
149149

150150
private static void addPhaseToMergeTestReports(Project project, String phaseName) {
151151
project.tasks.named(MERGE_TEST_REPORTS_TASK_NAME, TestReport) {
152152
it.testResults.from(
153-
project.files(project.layout.buildDirectory.dir("test-results/${phaseName}/binary"))
153+
project.files(project.layout.buildDirectory.dir("test-results/${phaseName}/binary")).filter { File f -> f.exists() }
154154
)
155155
}
156156
}

0 commit comments

Comments
 (0)