diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f2165d9d7..57b29de7a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -48,6 +48,7 @@ Christoph Wilhelms Christophe Labouisse Christopher A. Longo Christopher Charlier +Clark Archer Clemens Hammacher Clement OUDOT Conor MacNeill diff --git a/WHATSNEW b/WHATSNEW index bd3d15c7f..cd04d4e8c 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -96,6 +96,10 @@ Other changes: meaningful error message Bugzilla Report 48834 + * 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 ====================================== diff --git a/contributors.xml b/contributors.xml index 44b5cb193..57adce3a0 100644 --- a/contributors.xml +++ b/contributors.xml @@ -214,6 +214,10 @@ Christopher Charlier + + Clark + Archer + Clemens Hammacher diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index e30ae7ce2..fb99d836d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -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. @@ -812,6 +814,20 @@ public class JUnitTask extends Task { actOnTestResult(result, test, "Test " + test.getName()); } + /** + * Throws a BuildException if the given test name is invalid. + * Validity is defined as not null, not empty, and not the + * string "null". + * @param testName the test name to be validated + * @throws BuildException if testName 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. diff --git a/src/tests/antunit/taskdefs/optional/junit/junit-test.xml b/src/tests/antunit/taskdefs/optional/junit/junit-test.xml index 4613d23df..7755bf5ac 100644 --- a/src/tests/antunit/taskdefs/optional/junit/junit-test.xml +++ b/src/tests/antunit/taskdefs/optional/junit/junit-test.xml @@ -289,4 +289,13 @@ public class BTest extends TestCase { + + + + + + + + +