Author: rdonkin Date: Sun Dec 14 00:52:39 2008 New Revision: 726394 URL: http://svn.apache.org/viewvc?rev=726394&view=rev Log: Added errorproperty which allows ant build to continue after test fails.
Modified: james/mpt/trunk/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java james/mpt/trunk/antlib/src/site/xdoc/index.xml james/mpt/trunk/antlib/src/test/resources/build.xml Modified: james/mpt/trunk/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java URL: http://svn.apache.org/viewvc/james/mpt/trunk/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java?rev=726394&r1=726393&r2=726394&view=diff ============================================================================== --- james/mpt/trunk/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java (original) +++ james/mpt/trunk/antlib/src/main/java/org/apache/james/mpt/ant/MailProtocolTestTask.java Sun Dec 14 00:52:39 2008 @@ -56,8 +56,28 @@ private boolean skip = false; private String shabang = null; private Collection<AddUser> users = new ArrayList<AddUser>(); + private String errorProperty; /** + * Gets the error property. + * + * @return name of the ant property to be set on error, + * null if the script should terminate on error + */ + public String getErrorProperty() { + return errorProperty; + } + + /** + * Sets the error property. + * @param errorProperty name of the ant property to be set on error, + * nul if the script should terminate on error + */ + public void setErrorProperty(String errorProperty) { + this.errorProperty = errorProperty; + } + + /** * Should progress output be suppressed? * @return true if progress information should be suppressed, * false otherwise @@ -184,8 +204,16 @@ if(skip) { log("Skipping excution"); - } else { + } else if (errorProperty == null) { doExecute(); + } else { + try { + doExecute(); + } catch (BuildException e) { + final Project project = getProject(); + project.setProperty(errorProperty, e.getMessage()); + log(e, Project.MSG_DEBUG); + } } } @@ -209,7 +237,7 @@ scripts = new Union(); scripts.add(new FileResource(script)); } - + for (final Iterator it=scripts.iterator();it.hasNext();) { final Resource resource = (Resource) it.next(); try { Modified: james/mpt/trunk/antlib/src/site/xdoc/index.xml URL: http://svn.apache.org/viewvc/james/mpt/trunk/antlib/src/site/xdoc/index.xml?rev=726394&r1=726393&r2=726394&view=diff ============================================================================== --- james/mpt/trunk/antlib/src/site/xdoc/index.xml (original) +++ james/mpt/trunk/antlib/src/site/xdoc/index.xml Sun Dec 14 00:52:39 2008 @@ -89,6 +89,12 @@ <td>Optional boolean setting when true will suppress progress output.</td> <td>No (defaults to false)</td> </tr> +<tr> + <td>errorproperty</td> + <td>Optionally names a property which will be set (with error message) when test fails. + When unset, the build will terminate when test fails.</td> + <td>No</td> +</tr> </table> </subsection> Modified: james/mpt/trunk/antlib/src/test/resources/build.xml URL: http://svn.apache.org/viewvc/james/mpt/trunk/antlib/src/test/resources/build.xml?rev=726394&r1=726393&r2=726394&view=diff ============================================================================== --- james/mpt/trunk/antlib/src/test/resources/build.xml (original) +++ james/mpt/trunk/antlib/src/test/resources/build.xml Sun Dec 14 00:52:39 2008 @@ -78,6 +78,11 @@ </mpt:mpt> </target> + <target name='testMaySetErrorProperty'> + <mpt:mpt port='10000' skip='true' errorproperty='mpt.failed'> + <fileset dir='${basedir}' /> + </mpt:mpt> + </target> <target name='testShouldAllowAddUserToBeSet'> <mpt:mpt port='10000' skip='true' host='example.org'> @@ -128,7 +133,7 @@ </au:expectfailure> </target> - <target name='testMptAttributes' depends='testMustSetPort, testMaySetHost,testMustSetScriptsOrScript, testMustNotAllowScriptsAndScript, testMaySetShabang, testMaySetQuiet'/> + <target name='testMptAttributes' depends='testMustSetPort, testMaySetHost,testMustSetScriptsOrScript, testMustNotAllowScriptsAndScript, testMaySetShabang, testMaySetQuiet, testMaySetErrorProperty'/> <target name='testAddUser' depends='testShouldAllowAddUserToBeSet, testAddUserMustSetPortScript, testAddUserMayIncludeScriptText, testAddUserBothScriptTextAndScriptAttributeMayNotBeSet, testAddUserMaySetNamePassword'/> <target name='all' depends='testMptAttributes, testAddUser'/> --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org