|
|
@@ -20,18 +20,19 @@ package org.apache.tools.ant; |
|
|
|
|
|
|
|
import java.util.Vector; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Executor tests |
|
|
|
*/ |
|
|
|
public class ExecutorTest extends BuildFileTest implements BuildListener { |
|
|
|
private static final String SINGLE_CHECK |
|
|
|
= "org.apache.tools.ant.helper.SingleCheckExecutor"; |
|
|
|
private static final Vector targetNames; |
|
|
|
private static final String IGNORE_DEPS |
|
|
|
= "org.apache.tools.ant.helper.IgnoreDependenciesExecutor"; |
|
|
|
private static final Vector TARGET_NAMES; |
|
|
|
static { |
|
|
|
targetNames = new Vector(); |
|
|
|
targetNames.add("a"); |
|
|
|
targetNames.add("b"); |
|
|
|
TARGET_NAMES = new Vector(); |
|
|
|
TARGET_NAMES.add("a"); |
|
|
|
TARGET_NAMES.add("b"); |
|
|
|
} |
|
|
|
|
|
|
|
private int targetCount; |
|
|
@@ -76,52 +77,75 @@ public class ExecutorTest extends BuildFileTest implements BuildListener { |
|
|
|
} |
|
|
|
|
|
|
|
public void testDefaultExecutor() { |
|
|
|
getProject().executeTargets(targetNames); |
|
|
|
assertEquals(targetCount, 4); |
|
|
|
getProject().executeTargets(TARGET_NAMES); |
|
|
|
assertEquals(4, targetCount); |
|
|
|
} |
|
|
|
|
|
|
|
public void testSingleCheckExecutor() { |
|
|
|
getProject(SINGLE_CHECK).executeTargets(targetNames); |
|
|
|
assertEquals(targetCount, 3); |
|
|
|
getProject(SINGLE_CHECK).executeTargets(TARGET_NAMES); |
|
|
|
assertEquals(3, targetCount); |
|
|
|
} |
|
|
|
|
|
|
|
public void testIgnoreDependenciesExecutor() { |
|
|
|
getProject(IGNORE_DEPS).executeTargets(TARGET_NAMES); |
|
|
|
assertEquals(2, targetCount); |
|
|
|
} |
|
|
|
|
|
|
|
public void testDefaultFailure() { |
|
|
|
try { |
|
|
|
getProject(null, true).executeTargets(targetNames); |
|
|
|
getProject(null, true).executeTargets(TARGET_NAMES); |
|
|
|
fail("should fail"); |
|
|
|
} catch (BuildException e) { |
|
|
|
assertTrue(e.getMessage().equals("failfoo")); |
|
|
|
assertEquals(targetCount, 1); |
|
|
|
assertEquals(1, targetCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void testSingleCheckFailure() { |
|
|
|
try { |
|
|
|
getProject(SINGLE_CHECK, true).executeTargets(targetNames); |
|
|
|
getProject(SINGLE_CHECK, true).executeTargets(TARGET_NAMES); |
|
|
|
fail("should fail"); |
|
|
|
} catch (BuildException e) { |
|
|
|
assertTrue(e.getMessage().equals("failfoo")); |
|
|
|
assertEquals(targetCount, 1); |
|
|
|
assertEquals(1, targetCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void testIgnoreDependenciesFailure() { |
|
|
|
//no foo failure; foo is never executed as dependencies are ignored! |
|
|
|
getProject(IGNORE_DEPS, true).executeTargets(TARGET_NAMES); |
|
|
|
} |
|
|
|
|
|
|
|
public void testKeepGoingDefault() { |
|
|
|
try { |
|
|
|
getProject(null, true, true).executeTargets(targetNames); |
|
|
|
getProject(null, true, true).executeTargets(TARGET_NAMES); |
|
|
|
fail("should fail"); |
|
|
|
} catch (BuildException e) { |
|
|
|
assertTrue(e.getMessage().equals("failfoo")); |
|
|
|
assertEquals(targetCount, 2); |
|
|
|
assertEquals(2, targetCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void testKeepGoingSingleCheck() { |
|
|
|
try { |
|
|
|
getProject(SINGLE_CHECK, true, true).executeTargets(targetNames); |
|
|
|
getProject(SINGLE_CHECK, true, true).executeTargets(TARGET_NAMES); |
|
|
|
fail("should fail"); |
|
|
|
} catch (BuildException e) { |
|
|
|
assertTrue(e.getMessage().equals("failfoo")); |
|
|
|
assertEquals(1, targetCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void testKeepGoingIgnoreDependencies() { |
|
|
|
try { |
|
|
|
//explicitly add foo for failure |
|
|
|
Vector targetNames = new Vector(TARGET_NAMES); |
|
|
|
targetNames.add(0, "foo"); |
|
|
|
getProject(IGNORE_DEPS, true, true).executeTargets(targetNames); |
|
|
|
fail("should fail"); |
|
|
|
} catch (BuildException e) { |
|
|
|
assertTrue(e.getMessage().equals("failfoo")); |
|
|
|
assertEquals(targetCount, 1); |
|
|
|
assertEquals(3, targetCount); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|