@@ -168,23 +168,38 @@ target(allTests: "Runs the project's tests.") {
168168 filteredPhases. each { phase , types ->
169169 currentTestPhaseName = phase
170170
171- // Add a blank line before the start of this phase so that it
172- // is easier to distinguish
173- println ()
171+ def dirs = [:]
172+ types. each {
173+ def relativeSourcePath = it. relativeSourcePath
174+ if (relativeSourcePath) {
175+ def source = new File (testSourceDir, relativeSourcePath)
176+ if (source. exists()) {
177+ dirs[it] = [source : source, classes : new File (grailsSettings. testClassesDir, relativeSourcePath)]
178+ }
179+ }
180+ }
174181
175- event(" StatusUpdate" , [" Starting $phase test phase" ])
176- event(" TestPhaseStart" , [phase])
182+ if (dirs) {
183+ // Add a blank line before the start of this phase so that it
184+ // is easier to distinguish
185+ println ()
177186
178- " ${ phase} TestPhasePreparation" ()
187+ event(" StatusUpdate" , [" Starting $phase test phase" ])
188+ event(" TestPhaseStart" , [phase])
179189
180- // Now run all the tests registered for this phase.
181- types. each(processTests)
190+ " ${ phase} TestPhasePreparation" ()
191+
192+ // Now run all the tests registered for this phase.
193+ types. each {
194+ processTests(it, dirs[it]. source, dirs[it]. classes)
195+ }
182196
183- // Perform any clean up required.
184- this . " ${ phase} TestPhaseCleanUp" ()
197+ // Perform any clean up required.
198+ this . " ${ phase} TestPhaseCleanUp" ()
185199
186- event(" TestPhaseEnd" , [phase])
187- currentTestPhaseName = null
200+ event(" TestPhaseEnd" , [phase])
201+ currentTestPhaseName = null
202+ }
188203 }
189204 } finally {
190205 String msg = testsFailed ? " \n Tests FAILED" : " \n Tests PASSED"
@@ -205,20 +220,10 @@ target(allTests: "Runs the project's tests.") {
205220 * @param type The type of the tests to compile (not the test phase!)
206221 * For example, "unit", "jsunit", "webtest", etc.
207222 */
208- processTests = { GrailsTestType type ->
223+ processTests = { GrailsTestType type , File sourceDir , File classesDir ->
209224 currentTestTypeName = type. name
210-
211- def relativePathToSource = type. relativeSourcePath
212- def dest = null
213- if (relativePathToSource) {
214- def source = new File (" ${ testSourceDir} " , relativePathToSource)
215- if (! source. exists()) return // no source, no point continuing
216-
217- dest = new File (grailsSettings. testClassesDir, relativePathToSource)
218- compileTests(type, source, dest)
219- }
220-
221- runTests(type, dest)
225+ compileTests(type, sourceDir, classesDir)
226+ runTests(type, classesDir)
222227 currentTestTypeName = null
223228}
224229
0 commit comments