jhm 2004/02/18 00:17:15
Modified: src/testcases/org/apache/tools/ant ProjectTest.java
Added: src/etc/testcases/core duplicate-target.xml
Log:
Testcase for duplicate targets. Reported by Dominique Devienne.
Revision Changes Path
1.1 ant/src/etc/testcases/core/duplicate-target.xml
Index: duplicate-target.xml
===================================================================
<?xml version="1.0"?>
<project>
<target name="once">
<echo>once</echo>
</target>
<target name="twice">
<echo>twice-a</echo>
</target>
<target name="twice">
<echo>twice-b</echo>
</target>
</project>
1.22 +43 -2 ant/src/testcases/org/apache/tools/ant/ProjectTest.java
Index: ProjectTest.java
===================================================================
RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/ProjectTest.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ProjectTest.java 9 Feb 2004 21:05:40 -0000 1.21
+++ ProjectTest.java 18 Feb 2004 08:17:15 -0000 1.22
@@ -34,7 +34,8 @@
* Very limited test class for Project. Waiting to be extended.
*
* @author Stefan Bodewig
- */
+ * @author Jan Mat�rne
+*/
public class ProjectTest extends TestCase {
private Project p;
@@ -203,6 +204,13 @@
assertTrue(p.getTaskDefinitions().contains(org.apache.tools.ant.taskdefs.Echo.class));
}
+ // Bug in Ant 1.6/1.7 found by Dominique: there must no multiple
+ // targets with the same name in a project.
+ public void testDuplicateTargets() {
+ BFT bft = new BFT("", "core/duplicate-target.xml");
+ bft.expectBuildException("twice", "Duplicate target");
+ }
+
private class DummyTaskPrivate extends Task {
public DummyTaskPrivate() {}
public void execute() {}
@@ -213,9 +221,42 @@
public void execute() {}
}
+ private class BFT extends org.apache.tools.ant.BuildFileTest {
+ BFT(String name, String buildfile) {
+ super(name);
+ this.buildfile = buildfile;
+ setUp();
+ }
+
+ // avoid multiple configurations
+ boolean isConfigured = false;
+
+ // the buildfile to use
+ String buildfile = "";
+
+ public void setUp() {
+ if (!isConfigured) {
+ configureProject("src/etc/testcases/"+buildfile);
+ isConfigured = true;
+ }
+ }
+
+ public void tearDown() { }
+
+ // call a target
+ public void doTarget(String target) {
+ if (!isConfigured) setUp();
+ executeTarget(target);
+ }
+
+ public org.apache.tools.ant.Project getProject() {
+ return super.getProject();
+ }
+ }//class-BFT
+
}
class DummyTaskPackage extends Task {
public DummyTaskPackage() {}
public void execute() {}
-}
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]