ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/docs/manual/CoreTasks conditions.html
Date Fri, 20 May 2005 22:36:59 GMT
mbenson     2005/05/20 15:36:59

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/types defaults.properties
               docs/manual/CoreTasks conditions.html
  Added:       src/main/org/apache/tools/ant/taskdefs/condition
                        IsFailure.java
               src/testcases/org/apache/tools/ant/taskdefs/condition
                        IsFailureTest.java
               src/etc/testcases/taskdefs/conditions isfailure.xml
  Log:
  Add isfailure condition.
  
  Revision  Changes    Path
  1.828     +3 -1      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.827
  retrieving revision 1.828
  diff -u -r1.827 -r1.828
  --- WHATSNEW	20 May 2005 16:44:56 -0000	1.827
  +++ WHATSNEW	20 May 2005 22:36:58 -0000	1.828
  @@ -211,7 +211,9 @@
     As it tests for the implementation, it can be used to check for optional
     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
   ===================================
  
  
  
  1.41      +1 -0      ant/src/main/org/apache/tools/ant/types/defaults.properties
  
  Index: defaults.properties
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/defaults.properties,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- defaults.properties	16 May 2005 22:40:22 -0000	1.40
  +++ defaults.properties	20 May 2005 22:36:59 -0000	1.41
  @@ -44,3 +44,4 @@
   xor=org.apache.tools.ant.taskdefs.condition.Xor
   parsersupports=org.apache.tools.ant.taskdefs.condition.ParserSupports
   scriptmapper=org.apache.tools.ant.types.optional.ScriptMapper
  +isfailure=org.apache.tools.ant.taskdefs.condition.IsFailure
  
  
  
  1.1                  ant/src/main/org/apache/tools/ant/taskdefs/condition/IsFailure.java
  
  Index: IsFailure.java
  ===================================================================
  /*
   * 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);
      }
  
  }
  
  
  
  1.1                  ant/src/testcases/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java
  
  Index: IsFailureTest.java
  ===================================================================
  /*
   * 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 &lt;isfailure&gt; 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");
      }
  
  }
  
  
  
  1.1                  ant/src/etc/testcases/taskdefs/conditions/isfailure.xml
  
  Index: isfailure.xml
  ===================================================================
  <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>
  
  
  
  1.40      +18 -0     ant/docs/manual/CoreTasks/conditions.html
  
  Index: conditions.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/conditions.html,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- conditions.html	20 May 2005 16:33:15 -0000	1.39
  +++ conditions.html	20 May 2005 22:36:59 -0000	1.40
  @@ -640,6 +640,24 @@
   &lt;length file=&quot;foo&quot; when=&quot;greater&quot; length=&quot;0&quot;/&gt;
   </pre>
   
  +<h4>isfailure</h4>
  +
  +<p>Test the return code of an executable (see
  +<a href="exec.html">&lt;exec&gt;</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>
   <p align="center">Copyright &copy; 2001-2005 Apache Software
   Foundation. All rights Reserved.</p>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message