use of org.gradle.execution.TaskFailureHandler in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method testStopsExecutionOnFailureWhenFailureHandlerIndicatesThatExecutionShouldStop.
@Test
public void testStopsExecutionOnFailureWhenFailureHandlerIndicatesThatExecutionShouldStop() {
final TaskFailureHandler handler = context.mock(TaskFailureHandler.class);
final RuntimeException failure = new RuntimeException();
final RuntimeException wrappedFailure = new RuntimeException();
final Task a = brokenTask("a", failure);
final Task b = task("b");
taskExecuter.useFailureHandler(handler);
taskExecuter.addTasks(toList(a, b));
context.checking(new Expectations() {
{
one(handler).onTaskFailure(a);
will(throwException(wrappedFailure));
}
});
try {
taskExecuter.execute();
fail();
} catch (RuntimeException e) {
assertThat(e, sameInstance(wrappedFailure));
}
assertThat(executedTasks, equalTo(toList(a)));
}
use of org.gradle.execution.TaskFailureHandler in project gradle by gradle.
the class DefaultTaskGraphExecuterTest method willExecuteATaskWhoseDependenciesHaveBeenFilteredOnFailure.
@Test
public void willExecuteATaskWhoseDependenciesHaveBeenFilteredOnFailure() {
final TaskFailureHandler handler = context.mock(TaskFailureHandler.class);
final RuntimeException failure = new RuntimeException();
final Task a = brokenTask("a", failure);
final Task b = task("b");
final Task c = task("c", b);
taskExecuter.useFailureHandler(handler);
taskExecuter.useFilter(new Spec<Task>() {
public boolean isSatisfiedBy(Task element) {
return element != b;
}
});
taskExecuter.addTasks(toList(a, c));
context.checking(new Expectations() {
{
ignoring(handler);
}
});
try {
taskExecuter.execute();
fail();
} catch (RuntimeException e) {
assertThat(e, sameInstance(failure));
}
assertThat(executedTasks, equalTo(toList(a, c)));
}
Aggregations