Skip to content

Commit

Permalink
Fix issue #3 - Guard is not brave enough to handle compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
longwa committed Oct 9, 2012
1 parent 13bd600 commit 5729dd7
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions scripts/_Guard.groovy
@@ -1,3 +1,5 @@
import grails.util.Environment
import org.codehaus.groovy.grails.cli.ScriptExitException
import org.codehaus.groovy.grails.compiler.DirectoryWatcher
import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher
import org.codehaus.groovy.grails.test.junit4.JUnit4GrailsTestType
Expand Down Expand Up @@ -45,6 +47,10 @@ GuardFileChangeListener registerReloadingListener() {
* Main watch loop
*/
def watchLoop(GuardFileChangeListener listener, spock) {

// Prevent exit on compilation failure
System.setProperty("grails.disable.exit", "true")

//noinspection GroovyInfiniteLoopStatement
while(true) {
def changes = listener.consumeChanges()
Expand Down Expand Up @@ -73,16 +79,20 @@ def watchLoop(GuardFileChangeListener listener, spock) {
def mode = new GrailsTestMode(autowire: true, wrapInTransaction: true, wrapInRequestEnvironment: true)
def guardTestType = new JUnit4GrailsTestType("guard", "integration", mode)


// Run the tests
currentTestPhaseName = "guard"
processTests(guardTestType)

// Run Spock tests
if (spock) {
def specTestTypeClass = classLoader.loadClass('grails.plugin.spock.test.GrailsSpecTestType')
def specTestType = specTestTypeClass.newInstance('spock', "integration")
processTests(specTestType)
try {
currentTestPhaseName = "guard"
processTests(guardTestType)

// Run Spock tests
if (spock) {
def specTestTypeClass = classLoader.loadClass('grails.plugin.spock.test.GrailsSpecTestType')
def specTestType = specTestTypeClass.newInstance('spock', "integration")
processTests(specTestType)
}
}
catch( ScriptExitException e ) {
grailsConsole.error("Error running tests", e)
}

currentTestPhaseName = null
Expand Down

0 comments on commit 5729dd7

Please sign in to comment.