Permalink
Browse files

GRAILS-8168: Add functional test for GSP reloading , added gsp-reload…

…-app to build
  • Loading branch information...
1 parent 67fc591 commit 246b642bde79b56176319a40dc66c5f8dddd9406 @lhotari lhotari committed Oct 20, 2011
Showing with 39 additions and 27 deletions.
  1. +5 −2 apps/gsp-reload-app/test/functional/ReloadGSPTests.groovy
  2. +32 −23 build.xml
  3. +2 −2 common/macros.xml
@@ -3,6 +3,7 @@ import org.junit.Test
import static org.junit.Assert.*
import java.io.File
import grails.util.Environment
+import grails.util.BuildSettingsHolder
class ReloadGSPTests extends GebReportingTest {
@Test
@@ -12,7 +13,9 @@ class ReloadGSPTests extends GebReportingTest {
assert heading == 'Hello'
assert message == 'Hello world'
- File gspFile = new File("target/work/war/WEB-INF/grails-app/views/hello/index.gsp")
+ File warDir = new File(BuildSettingsHolder.settings.projectWorkDir, 'war')
+
+ File gspFile = new File(warDir, "WEB-INF/grails-app/views/hello/index.gsp")
def oldContent = gspFile.text
def newContent = '''<html>
<head><title>Hello</title></head>
@@ -42,7 +45,7 @@ class ReloadGSPTests extends GebReportingTest {
assert heading == 'Hello layout'
assert message == 'Hello world with layout'
- File layoutFile = new File("target/work/war/WEB-INF/grails-app/views/layouts/main.gsp")
+ File layoutFile = new File(warDir, "WEB-INF/grails-app/views/layouts/main.gsp")
def layoutContent = layoutFile.text
layoutFile.text = layoutContent + "<!--LAYOUT UPDATED-->"
// wait 2 * default timeout
View
@@ -110,9 +110,6 @@
// skip webtest based tests until plugin is fixed
if (properties.projectName == 'HelloWorld') return
- // skip gsp-reload-app for now
- if (properties.projectName == 'gsp-reload-app') return
-
// if the appToTest system property is set, then skip all other apps
if (properties.appToTest && !properties.appToTest.equals(properties.projectName)) {
ant.echo message: "Skipping app: ${properties.projectName}"
@@ -137,30 +134,42 @@
// Install the appropriate testing plugin, run the tests, and check the reportsDir
if (new File(appDir, "test/functional").exists()) {
- // Install the Functional Test plugin.
- ant.grails(command:"install-plugin", args:"functional-test 1.2.7", projectName:properties.projectName, resultID:grailsInvocationCounter++)
- if (properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) {
- outcomes << "Couldn't install functional-test plugin into application ${properties.projectName}"
- failure = true
- }
-
- // Run the tests.
- ant.grails(command:"test-app", args: "functional: --dev-mode", environment:"dev", projectName:properties.projectName, resultID:grailsInvocationCounter++)
- outcomes << "Functional tests in application ${properties.projectName}: " +
- ((properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) ? "Failed" : "OK")
-
- if (properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) {
- failure = true
+ if(!(properties.projectName in ['gsp-reload-app'])) {
+ // Install the Functional Test plugin.
+ ant.grails(command:"install-plugin", args:"functional-test 1.2.7", projectName:properties.projectName, resultID:grailsInvocationCounter++)
+ if (properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) {
+ outcomes << "Couldn't install functional-test plugin into application ${properties.projectName}"
+ failure = true
+ }
+ } else {
+ // Workaround for GRAILS-8189
+ ant.grails(command:'compile', projectName:properties.projectName, resultID:grailsInvocationCounter++)
}
-
- // Copy reports
- ant.mkdir(dir:"reports/${properties.projectName}")
- ant.copy(todir:"reports/${properties.projectName}") {
- fileset(dir:"${properties.checkoutDir}/${properties.projectName}/target/test-reports")
+
+ if(!(properties.projectName in ['gsp-reload-app'])) {
+ // Run the tests.
+ ant.grails(command:"test-app", args: "functional: --dev-mode", environment:"dev", projectName:properties.projectName, resultID:grailsInvocationCounter++)
+ outcomes << "Functional tests in application ${properties.projectName}: " +
+ ((properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) ? "Failed" : "OK")
+
+ if (properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) {
+ failure = true
+ }
+
+ // Copy reports
+ ant.mkdir(dir:"reports/${properties.projectName}")
+ ant.copy(todir:"reports/${properties.projectName}") {
+ fileset(dir:"${properties.checkoutDir}/${properties.projectName}/target/test-reports")
+ }
}
// Run the WAR tests.
- ant.grails(command:"test-app", args: "-war functional: --dev-mode", environment:"test", projectName:properties.projectName, resultID:grailsInvocationCounter++)
+ def grailsWarTestCmdArgs = [command:"test-app", args: "-war functional: --dev-mode", environment:"test", projectName:properties.projectName, resultID:grailsInvocationCounter++]
+ if(properties.projectName in ['gsp-reload-app']) {
+ grailsWarTestCmdArgs.args='functional: -war'
+ grailsWarTestCmdArgs.environment='production'
+ }
+ ant.grails(grailsWarTestCmdArgs)
outcomes << "Functional tests in application ${properties.projectName}: " +
((properties["testResult_${grailsInvocationCounter-1}"].toInteger() != 0) ? "Failed" : "OK")
View
@@ -3,7 +3,7 @@
<macrodef name="grails">
<attribute name="command" description="the command line to execute"/>
<attribute name="args" default="" description="the arguments to pass to the command"/>
- <attribute name="environment" default="" description="The environment to use for the command."/>
+ <attribute name="environment" default="development" description="The environment to use for the command."/>
<attribute name="projectName" default=""/>
<attribute name="resultID" default="0"/>
<attribute name="dir" default="${checkoutDir}/@{projectName}"/>
@@ -19,7 +19,7 @@
<arg value="-Dgrails.work.dir=${basedir}/work-global/@{projectName}_grailsWorkDir/"/>
<arg value="-Dgrails.project.work.dir=${basedir}/work-global/@{projectName}_grailsProjectWorkDir/"/>
<arg value="-Dgrails.project.plugins.dir=${basedir}/work-global/@{projectName}_grailsProjectPluginsDir/"/>
- <arg value="@{environment}"/>
+ <arg value="-Dgrails.env=@{environment}"/>
<arg value="@{command}"/>
<arg value="--non-interactive"/>
<arg line="@{args}"/>

0 comments on commit 246b642

Please sign in to comment.