ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r926465 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java src/tests/antunit/taskdefs/optional/junit/junit-test.xml
Date Tue, 23 Mar 2010 05:26:12 GMT
Author: bodewig
Date: Tue Mar 23 05:26:11 2010
New Revision: 926465

URL: http://svn.apache.org/viewvc?rev=926465&view=rev
Log:
reject empty test names.  Submitted by Clark Archer.  PR 43586

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
    ant/core/trunk/src/tests/antunit/taskdefs/optional/junit/junit-test.xml

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=926465&r1=926464&r2=926465&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=926465&r1=926464&r2=926465&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Mar 23 05:26:11 2010
@@ -96,6 +96,10 @@ Other changes:
    meaningful error message
    Bugzilla Report 48834
    
+ * <junit> will now throw an exception if a test name is empty.  This
+   used to manifest itself in unrelated errors like
+   Bugzilla Report 43586.
+
 Changes from Ant 1.8.0RC1 TO Ant 1.8.0
 ======================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=926465&r1=926464&r2=926465&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Tue Mar 23 05:26:11 2010
@@ -215,6 +215,10 @@
     <last>Charlier</last>
   </name>
   <name>
+    <first>Clark</first>
+    <last>Archer</last>
+  </name>
+  <name>
     <first>Clemens</first>
     <last>Hammacher</last>
   </name>

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=926465&r1=926464&r2=926465&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
Mar 23 05:26:11 2010
@@ -789,6 +789,8 @@ public class JUnitTask extends Task {
      * @throws BuildException in case of test failures or errors
      */
     protected void execute(JUnitTest arg) throws BuildException {
+        validateTestName(arg.getName());
+
         JUnitTest test = (JUnitTest) arg.clone();
         // set the default values if not specified
         //@todo should be moved to the test class instead.
@@ -813,6 +815,20 @@ public class JUnitTask extends Task {
     }
 
     /**
+     * Throws a <code>BuildException</code> if the given test name is invalid.
+     * Validity is defined as not <code>null</code>, not empty, and not the
+     * string &quot;null&quot;.
+     * @param testName the test name to be validated
+     * @throws BuildException if <code>testName</code> is not a valid test name
+     */
+    private void validateTestName(String testName) throws BuildException {
+        if (testName == null || testName.length() == 0
+            || testName.equals("null")) {
+            throw new BuildException("test name must be specified");
+        }
+    }
+
+    /**
      * Execute a list of tests in a single forked Java VM.
      * @param testList the list of tests to execute.
      * @throws BuildException on error.

Modified: ant/core/trunk/src/tests/antunit/taskdefs/optional/junit/junit-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/junit/junit-test.xml?rev=926465&r1=926464&r2=926465&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/junit/junit-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/junit/junit-test.xml Tue Mar 23 05:26:11
2010
@@ -289,4 +289,13 @@ public class BTest extends TestCase {
     <au:assertLogDoesntContain text="Running test.HTest"/>
   </target>
 
+  <target name="testMissingTestName">
+    <property name="test.name" value="null"/>
+    <au:expectfailure message="test name must be specified">
+      <junit fork="false">
+        <test name="${test.name}"/>
+      </junit>
+    </au:expectfailure>
+  </target>
+
 </project>



Mime
View raw message