ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r405524 - in /ant/core/trunk/src: main/org/apache/tools/ant/taskdefs/Execute.java main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
Date Tue, 09 May 2006 20:25:51 GMT
Author: stevel
Date: Tue May  9 13:25:48 2006
New Revision: 405524

URL: http://svn.apache.org/viewcvs?rev=405524&view=rev
Log:
Adding a new non-static method, isFailure() to Execute. As well as simplifying a common operation,
it is a foundation for instance specific logic to decide if an execute failed, which could
be of use in VMS land.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
    ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java?rev=405524&r1=405523&r2=405524&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Execute.java Tue May  9 13:25:48
2006
@@ -47,7 +47,9 @@
  */
 public class Execute {
 
-    /** Invalid exit code. **/
+    /** Invalid exit code. 
+     * set to {@link Integer#MAX_VALUE}
+     */
     public static final int INVALID = Integer.MAX_VALUE;
 
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
@@ -584,6 +586,16 @@
         // for other platforms nonzero exit value signals failure
         return Os.isFamily("openvms")
             ? (exitValue % 2 == 0) : (exitValue != 0);
+    }
+
+    /**
+     * Did this execute return in a failure.
+     * @see #isFailure(int) 
+     * @return true if and only if the exit code is interpreted as a failure
+     * @since Ant1.7
+     */
+    public boolean isFailure() {
+        return isFailure(getExitValue());
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java?rev=405524&r1=405523&r2=405524&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/rmic/ForkingSunRmic.java Tue May
 9 13:25:48 2006
@@ -65,9 +65,8 @@
             exe.setAntRun(project);
             exe.setWorkingDirectory(project.getBaseDir());
             exe.setCommandline(args);
-
             exe.execute();
-            return exe.getExitValue() == 0;
+            return !exe.isFailure();
         } catch (IOException exception) {
             throw new BuildException("Error running " + SunRmic.RMIC_EXECUTABLE
                     + " -maybe it is not on the path", exception);

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java?rev=405524&r1=405523&r2=405524&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java (original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java Tue
May  9 13:25:48 2006
@@ -27,12 +27,12 @@
  */
 public class ExecuteWatchdogTest extends TestCase {
 
-    private final static int TIME_OUT = 5000;
+    private final static long TIME_OUT = 5000;
 
     private final static String TEST_CLASSPATH = getTestClassPath();
 
     private final static int CLOCK_ERROR=200;
-    private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR;
+    private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR;
 
     private ExecuteWatchdog watchdog;
 
@@ -58,7 +58,7 @@
         return classpath;
     }
 
-    private Process getProcess(int timetorun) throws Exception {
+    private Process getProcess(long timetorun) throws Exception {
         String[] cmdArray = {
             JavaEnvUtils.getJreExecutable("java"), "-classpath", TEST_CLASSPATH,
             TimeProcess.class.getName(), String.valueOf(timetorun)
@@ -94,7 +94,7 @@
         watchdog.start(process);
         int retCode = waitForEnd(process);
         assertTrue("process should not have been killed", !watchdog.killedProcess());
-        assertEquals(0, retCode);
+        assertFalse(Execute.isFailure(retCode));
     }
 
     // test that the watchdog ends the process



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


Mime
View raw message