ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r805415 - in /ant/core/trunk: ./ docs/manual/OptionalTasks/ src/main/org/apache/tools/ant/taskdefs/optional/junit/
Date Tue, 18 Aug 2009 13:55:47 GMT
Author: bodewig
Date: Tue Aug 18 13:55:46 2009
New Revision: 805415

URL: http://svn.apache.org/viewvc?rev=805415&view=rev
Log:
option to suppress FAILED lines in JUnit log output.  PR 35073

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/OptionalTasks/junit.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=805415&r1=805414&r2=805415&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Aug 18 13:55:46 2009
@@ -847,6 +847,10 @@
    <javac>.
    Bugzilla Report 24359.
 
+ * It is now possible to suppress the "FAILED" lines sent to Ant's
+   logging system via <junit>'s new logFailedTests attribute.
+   Bugzilla Report 35073.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/OptionalTasks/junit.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/junit.html?rev=805415&r1=805414&r2=805415&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/junit.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/junit.html Tue Aug 18 13:55:46 2009
@@ -228,6 +228,16 @@
       <em>since Ant 1.7</em></td>
     <td align="center" valign="top">No</td>
   </tr>
+  <tr>
+    <td valign="top">logfailedtests</td>
+    <td valign="top">When Ant executes multiple tests and doesn't stop
+      on errors or failures it will log a "FAILED" message for each
+      failing test to its logging system.  If you set this option to
+      false, the message will not be logged and you have to rely on the
+      formatter output to find the failing tests.
+      <em>since Ant 1.8.0</em></td>
+    <td align="center" valign="top">No</td>
+  </tr>    
 </table>
 
 <p>By using the <code>errorproperty</code> and <code>failureproperty</code>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java?rev=805415&r1=805414&r2=805415&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java Tue
Aug 18 13:55:46 2009
@@ -35,4 +35,5 @@
     static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents=";
     static final String TESTSFILE = "testsfile=";
     static final String TERMINATED_SUCCESSFULLY = "terminated successfully";
+    static final String LOG_FAILED_TESTS="logfailedtests=";
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java?rev=805415&r1=805414&r2=805415&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Tue
Aug 18 13:55:46 2009
@@ -155,6 +155,8 @@
     // Do we send output to the formatters ?
     private boolean outputToFormatters = true;
 
+    private boolean logFailedTests = true;
+
     private File tmpDir;
     private AntClassLoader classLoader = null;
     private Permissions perm = null;
@@ -597,6 +599,16 @@
     }
 
     /**
+     * If true, write a single "FAILED" line for failed tests to Ant's
+     * log system.
+     *
+     * @since Ant 1.8.0
+     */
+    public void setLogFailedTests(boolean logFailedTests) {
+        this.logFailedTests = logFailedTests;
+    }
+
+    /**
      * Assertions to enable in this program (if fork=true)
      * @since Ant 1.6
      * @param asserts assertion set
@@ -949,6 +961,8 @@
                                       + String.valueOf(showOutput));
         cmd.createArgument().setValue(Constants.OUTPUT_TO_FORMATTERS
                                       + String.valueOf(outputToFormatters));
+        cmd.createArgument().setValue(Constants.LOG_FAILED_TESTS
+                                      + String.valueOf(logFailedTests));
 
         cmd.createArgument().setValue(
             Constants.LOGTESTLISTENEREVENTS + "true"); // #31885
@@ -1865,9 +1879,12 @@
                     + (result.timedOut ? " (timeout)" : "")
                     + (result.crashed ? " (crashed)" : ""), getLocation());
             } else {
-                log(name + " FAILED"
-                    + (result.timedOut ? " (timeout)" : "")
-                    + (result.crashed ? " (crashed)" : ""), Project.MSG_ERR);
+                if (logFailedTests) {
+                    log(name + " FAILED"
+                        + (result.timedOut ? " (timeout)" : "")
+                        + (result.crashed ? " (crashed)" : ""),
+                        Project.MSG_ERR);
+                }
                 if (errorOccurredHere && test.getErrorProperty() != null) {
                     getProject().setNewProperty(test.getErrorProperty(), "true");
                 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java?rev=805415&r1=805414&r2=805415&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
Tue Aug 18 13:55:46 2009
@@ -680,6 +680,7 @@
         Properties props = new Properties();
         boolean showOut = false;
         boolean outputToFormat = true;
+        boolean logFailedTests = true;
         boolean logTestListenerEvents = false;
 
 
@@ -723,6 +724,9 @@
             } else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) {
                 outputToFormat = Project.toBoolean(
                     args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length()));
+            } else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) {
+                logFailedTests = Project.toBoolean(
+                    args[i].substring(Constants.LOG_FAILED_TESTS.length()));
             }
         }
 
@@ -764,8 +768,10 @@
                             if (code > returnCode) {
                                 returnCode = code;
                             }
-                            System.out.println("TEST " + t.getName()
-                                               + " FAILED");
+                            if (logFailedTests) {
+                                System.out.println("TEST " + t.getName()
+                                                   + " FAILED");
+                            }
                         }
                     }
                 }



Mime
View raw message