git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278314 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -211,7 +211,9 @@ Other changes: | |||||
| As it tests for the implementation, it can be used to check for optional | As it tests for the implementation, it can be used to check for optional | ||||
| tasks being available. | tasks being available. | ||||
| * check for 1.5.* ant main class. (weblogic.jar in classpath reports) | |||||
| * check for 1.5.* Ant main class. (weblogic.jar in classpath reports) | |||||
| * New condition <isfailure> that tests the return-code of an executable. | |||||
| Changes from Ant 1.6.3 to Ant 1.6.4 | Changes from Ant 1.6.3 to Ant 1.6.4 | ||||
| =================================== | =================================== | ||||
| @@ -640,6 +640,24 @@ Verify a file is not empty: | |||||
| <length file="foo" when="greater" length="0"/> | <length file="foo" when="greater" length="0"/> | ||||
| </pre> | </pre> | ||||
| <h4>isfailure</h4> | |||||
| <p>Test the return code of an executable (see | |||||
| <a href="exec.html"><exec></a>) for failure. <b>Since Ant 1.7</b></p> | |||||
| <table border="1" cellpadding="2" cellspacing="0"> | |||||
| <tr> | |||||
| <td valign="top"><b>Attribute</b></td> | |||||
| <td valign="top"><b>Description</b></td> | |||||
| <td align="center" valign="top"><b>Required</b></td> | |||||
| </tr> | |||||
| <tr> | |||||
| <td valign="top">code</td> | |||||
| <td valign="top">The return code to test.</td> | |||||
| <td valign="top" align="center">Yes</td> | |||||
| </tr> | |||||
| </table> | |||||
| <hr> | <hr> | ||||
| <p align="center">Copyright © 2001-2005 Apache Software | <p align="center">Copyright © 2001-2005 Apache Software | ||||
| Foundation. All rights Reserved.</p> | Foundation. All rights Reserved.</p> | ||||
| @@ -0,0 +1,48 @@ | |||||
| <project default="testisfailure"> | |||||
| <target name="testisfailure"> | |||||
| <fail> | |||||
| <condition> | |||||
| <or> | |||||
| <and> | |||||
| <os family="openvms" /> | |||||
| <or> | |||||
| <isfailure code="1" /> | |||||
| <isfailure code="3" /> | |||||
| <isfailure code="5" /> | |||||
| <isfailure code="7" /> | |||||
| <isfailure code="9" /> | |||||
| <not> | |||||
| <and> | |||||
| <isfailure code="0" /> | |||||
| <isfailure code="2" /> | |||||
| <isfailure code="4" /> | |||||
| <isfailure code="6" /> | |||||
| <isfailure code="8" /> | |||||
| </and> | |||||
| </not> | |||||
| </or> | |||||
| </and> | |||||
| <and> | |||||
| <not> | |||||
| <os family="openvms" /> | |||||
| </not> | |||||
| <or> | |||||
| <isfailure code="0" /> | |||||
| <not> | |||||
| <and> | |||||
| <isfailure code="1" /> | |||||
| <isfailure code="10" /> | |||||
| <isfailure code="50" /> | |||||
| <isfailure code="100" /> | |||||
| <isfailure code="255" /> | |||||
| </and> | |||||
| </not> | |||||
| </or> | |||||
| </and> | |||||
| </or> | |||||
| </condition> | |||||
| </fail> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,53 @@ | |||||
| /* | |||||
| * Copyright 2005 The Apache Software Foundation | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| * | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.taskdefs.Execute; | |||||
| /** | |||||
| * Condition to test a return-code for failure. | |||||
| * @since Ant 1.7 | |||||
| */ | |||||
| public class IsFailure implements Condition { | |||||
| private int code; | |||||
| /** | |||||
| * Set the return code to check. | |||||
| * @param c the return code. | |||||
| */ | |||||
| public void setCode(int c) { | |||||
| code = c; | |||||
| } | |||||
| /** | |||||
| * Get the return code that will be checked by this IsFailure condition. | |||||
| * @return return code as int. | |||||
| */ | |||||
| public int getCode() { | |||||
| return code; | |||||
| } | |||||
| /** | |||||
| * Fulfill the condition interface. | |||||
| * @return the result of evaluating the specified return code. | |||||
| */ | |||||
| public boolean eval() { | |||||
| return Execute.isFailure(code); | |||||
| } | |||||
| } | |||||
| @@ -44,3 +44,4 @@ scriptcondition=org.apache.tools.ant.types.optional.ScriptCondition | |||||
| xor=org.apache.tools.ant.taskdefs.condition.Xor | xor=org.apache.tools.ant.taskdefs.condition.Xor | ||||
| parsersupports=org.apache.tools.ant.taskdefs.condition.ParserSupports | parsersupports=org.apache.tools.ant.taskdefs.condition.ParserSupports | ||||
| scriptmapper=org.apache.tools.ant.types.optional.ScriptMapper | scriptmapper=org.apache.tools.ant.types.optional.ScriptMapper | ||||
| isfailure=org.apache.tools.ant.taskdefs.condition.IsFailure | |||||
| @@ -0,0 +1,42 @@ | |||||
| /* | |||||
| * Copyright 2005 The Apache Software Foundation | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| * | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs.condition; | |||||
| import org.apache.tools.ant.BuildFileTest; | |||||
| /** | |||||
| * Testcases for the <isfailure> condition. | |||||
| * | |||||
| */ | |||||
| public class IsFailureTest extends BuildFileTest { | |||||
| public IsFailureTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| /** | |||||
| * The JUnit setup method | |||||
| */ | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/conditions/isfailure.xml"); | |||||
| } | |||||
| public void testIsFailure() { | |||||
| executeTarget("testisfailure"); | |||||
| } | |||||
| } | |||||