Browse Source

Another testcase for double target-definition

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276126 13f79535-47bb-0310-9956-ffa450edef68
master
Jan Materne 21 years ago
parent
commit
caf0645f58
3 changed files with 25 additions and 2 deletions
  1. +7
    -0
      src/etc/testcases/core/duplicate-target-imported.xml
  2. +10
    -0
      src/etc/testcases/core/duplicate-target2.xml
  3. +8
    -2
      src/testcases/org/apache/tools/ant/ProjectTest.java

+ 7
- 0
src/etc/testcases/core/duplicate-target-imported.xml View File

@@ -0,0 +1,7 @@
<?xml version="1.0"?>

<project>
<target name="once">
<echo>once from imported</echo>
</target>
</project>

+ 10
- 0
src/etc/testcases/core/duplicate-target2.xml View File

@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<project>

<import file="duplicate-target-imported.xml"/>

<target name="once">
<echo>once from buildfile</echo>
</target>
</project>

+ 8
- 2
src/testcases/org/apache/tools/ant/ProjectTest.java View File

@@ -204,13 +204,19 @@ public class ProjectTest extends TestCase {
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() {
// fail, because buildfile contains two targets with the same name
BFT bft = new BFT("", "core/duplicate-target.xml");
bft.expectBuildException("twice", "Duplicate target");
}

public void testDuplicateTargetsImport() {
// overriding target from imported buildfile is allowed
BFT bft = new BFT("", "core/duplicate-target2.xml");
bft.expectLog("once", "once from buildfile");
}


private class DummyTaskPrivate extends Task {
public DummyTaskPrivate() {}
public void execute() {}


Loading…
Cancel
Save