ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1524979 - in /ant/core/trunk: WHATSNEW src/etc/testcases/taskdefs/parallel.xml src/main/org/apache/tools/ant/taskdefs/Parallel.java src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java
Date Fri, 20 Sep 2013 11:48:13 GMT
Author: bodewig
Date: Fri Sep 20 11:48:12 2013
New Revision: 1524979

URL: http://svn.apache.org/r1524979
Log:
don't swallow fail's status in parallel - PR 55539

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/etc/testcases/taskdefs/parallel.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1524979&r1=1524978&r2=1524979&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Sep 20 11:48:12 2013
@@ -17,6 +17,9 @@ Other changes:
  * tar entries with long link names are now handled the same way as
    entries with long names.
 
+ * <parallel> swallowed the status code of nested <fail> tasks.
+   Bugzilla Report 55539
+
 Changes from Ant 1.9.1 TO Ant 1.9.2
 ===================================
 

Modified: ant/core/trunk/src/etc/testcases/taskdefs/parallel.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/parallel.xml?rev=1524979&r1=1524978&r2=1524979&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/parallel.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/parallel.xml Fri Sep 20 11:48:12 2013
@@ -142,6 +142,20 @@
     </parallel>
   </target>
   
+  <target name="testSingleExit">
+    <parallel>
+      <echo message="all is well"/>
+      <fail message="no it isn't" status="42"/>
+    </parallel>
+  </target>
+
+  <target name="testExitAndOtherException">
+    <parallel>
+      <fail message="no it isn't"/>
+      <fail message="no it isn't" status="42"/>
+    </parallel>
+  </target>
+
   <target name="help">
     <echo>Test build file for the &lt;parallel&gt; task.</echo> 
     <echo>Use the various targets to run the tests.</echo>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java?rev=1524979&r1=1524978&r2=1524979&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Parallel.java Fri Sep 20 11:48:12
2013
@@ -22,6 +22,7 @@ import java.util.Vector;
 import java.util.List;
 import java.util.ArrayList;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.ExitStatusException;
 import org.apache.tools.ant.Location;
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.TaskContainer;
@@ -109,6 +110,9 @@ public class Parallel extends Task
     /** The location of the first exception */
     private Location firstLocation;
 
+    /** The status of the first ExitStatusException. */
+    private Integer firstExitStatus;
+
     /**
      * Add a group of daemon threads
      * @param daemonTasks The tasks to be executed as daemon.
@@ -230,6 +234,14 @@ public class Parallel extends Task
                     && firstLocation == Location.UNKNOWN_LOCATION) {
                     firstLocation = ((BuildException) t).getLocation();
                 }
+                if (t instanceof ExitStatusException
+                    && firstExitStatus == null) {
+                    ExitStatusException ex = (ExitStatusException) t;
+                    firstExitStatus = ex.getStatus();
+                    // potentially overwriting existing value but the
+                    // location should match the exit status
+                    firstLocation = ex.getLocation();
+                }
                 exceptionMessage.append(StringUtils.LINE_SEP);
                 exceptionMessage.append(t.getMessage());
             }
@@ -366,6 +378,7 @@ public class Parallel extends Task
         exceptionMessage = new StringBuffer();
         numExceptions = 0;
         firstException = null;
+        firstExitStatus = null;
         firstLocation = Location.UNKNOWN_LOCATION;
         processExceptions(daemons);
         processExceptions(runnables);
@@ -377,8 +390,13 @@ public class Parallel extends Task
                 throw new BuildException(firstException);
             }
         } else if (numExceptions > 1) {
-            throw new BuildException(exceptionMessage.toString(),
-                                     firstLocation);
+            if (firstExitStatus == null) {
+                throw new BuildException(exceptionMessage.toString(),
+                                         firstLocation);
+            } else {
+                throw new ExitStatusException(exceptionMessage.toString(),
+                                              firstExitStatus, firstLocation);
+            }
         }
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java?rev=1524979&r1=1524978&r2=1524979&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java Fri Sep
20 11:48:12 2013
@@ -16,12 +16,14 @@
  *
  */
 package org.apache.tools.ant.taskdefs;
+
 import java.io.PrintStream;
 
 import junit.framework.AssertionFailedError;
 
 import org.apache.tools.ant.BuildFileTest;
 import org.apache.tools.ant.DemuxOutputStream;
+import org.apache.tools.ant.ExitStatusException;
 import org.apache.tools.ant.Project;
 
 /**
@@ -150,5 +152,27 @@ public class ParallelTest extends BuildF
         }
     }
 
+    /**
+     * @see "https://issues.apache.org/bugzilla/show_bug.cgi?id=55539"
+     */
+    public void testSingleExit() {
+        try {
+            executeTarget("testSingleExit");
+        } catch (ExitStatusException ex) {
+            assertEquals(42, ex.getStatus());
+        }
+    }
+
+    /**
+     * @see "https://issues.apache.org/bugzilla/show_bug.cgi?id=55539"
+     */
+    public void testExitAndOtherException() {
+        try {
+            executeTarget("testExitAndOtherException");
+        } catch (ExitStatusException ex) {
+            assertEquals(42, ex.getStatus());
+        }
+    }
+
 }
 



Mime
View raw message