Search in sources :

Example 1 with TaskStateInternal

use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.

the class DefaultTaskGraphExecuterTest method createTask.

private TaskInternal createTask(final String name) {
    TaskInternal task = context.mock(TaskInternal.class);
    TaskStateInternal state = context.mock(TaskStateInternal.class);
    final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
    setExpectations(name, task, state, outputs);
    return task;
}
Also used : TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskInternal(org.gradle.api.internal.TaskInternal) DefaultTaskOutputs(org.gradle.api.internal.tasks.DefaultTaskOutputs) TaskOutputs(org.gradle.api.tasks.TaskOutputs)

Example 2 with TaskStateInternal

use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.

the class DefaultTaskGraphExecuterTest method task.

private Task task(final String name, final Task... dependsOn) {
    final TaskInternal task = context.mock(TaskInternal.class);
    final TaskStateInternal state = context.mock(TaskStateInternal.class);
    final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
    setExpectations(name, task, state, outputs);
    dependsOn(task, dependsOn);
    context.checking(new Expectations() {

        {
            atMost(1).of(executer).execute(with(sameInstance(task)), with(sameInstance(state)), with(notNullValue(TaskExecutionContext.class)));
            will(new ExecuteTaskAction(task));
            allowing(state).getFailure();
            will(returnValue(null));
        }
    });
    return task;
}
Also used : Expectations(org.jmock.Expectations) TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskInternal(org.gradle.api.internal.TaskInternal) DefaultTaskOutputs(org.gradle.api.internal.tasks.DefaultTaskOutputs) TaskOutputs(org.gradle.api.tasks.TaskOutputs) TaskExecutionContext(org.gradle.api.internal.tasks.TaskExecutionContext)

Example 3 with TaskStateInternal

use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.

the class DefaultTaskGraphExecuterTest method brokenTask.

private Task brokenTask(String name, final RuntimeException failure, final Task... dependsOn) {
    final TaskInternal task = context.mock(TaskInternal.class);
    final TaskStateInternal state = context.mock(TaskStateInternal.class);
    final TaskOutputs outputs = context.mock(DefaultTaskOutputs.class);
    setExpectations(name, task, state, outputs);
    dependsOn(task, dependsOn);
    context.checking(new Expectations() {

        {
            atMost(1).of(executer).execute(with(sameInstance(task)), with(sameInstance(state)), with(notNullValue(TaskExecutionContext.class)));
            will(new ExecuteTaskAction(task));
            allowing(state).getFailure();
            will(returnValue(failure));
            allowing(state).rethrowFailure();
            will(throwException(failure));
        }
    });
    return task;
}
Also used : Expectations(org.jmock.Expectations) TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskInternal(org.gradle.api.internal.TaskInternal) DefaultTaskOutputs(org.gradle.api.internal.tasks.DefaultTaskOutputs) TaskOutputs(org.gradle.api.tasks.TaskOutputs) TaskExecutionContext(org.gradle.api.internal.tasks.TaskExecutionContext)

Example 4 with TaskStateInternal

use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.

the class TaskExecutionStatisticsEventAdapter method afterExecute.

@Override
public void afterExecute(Task task, TaskState state) {
    TaskStateInternal stateInternal = (TaskStateInternal) state;
    TaskExecutionOutcome outcome = stateInternal.getOutcome();
    taskCounts.put(outcome, taskCounts.get(outcome) + 1);
    if (outcome == TaskExecutionOutcome.EXECUTED && stateInternal.getTaskOutputCaching().isEnabled()) {
        cacheMissCount++;
    }
}
Also used : TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) TaskExecutionOutcome(org.gradle.api.internal.tasks.TaskExecutionOutcome)

Example 5 with TaskStateInternal

use of org.gradle.api.internal.tasks.TaskStateInternal in project gradle by gradle.

the class ClientForwardingTaskOperationListener method toTaskResult.

private static AbstractTaskResult toTaskResult(TaskInternal task, OperationResult result) {
    TaskStateInternal state = task.getState();
    long startTime = result.getStartTime();
    long endTime = result.getEndTime();
    if (state.getUpToDate()) {
        return new DefaultTaskSuccessResult(startTime, endTime, true, state.isFromCache(), state.getSkipMessage());
    } else if (state.getSkipped()) {
        return new DefaultTaskSkippedResult(startTime, endTime, state.getSkipMessage());
    } else {
        Throwable failure = result.getFailure();
        if (failure == null) {
            return new DefaultTaskSuccessResult(startTime, endTime, false, state.isFromCache(), "SUCCESS");
        } else {
            return new DefaultTaskFailureResult(startTime, endTime, Collections.singletonList(DefaultFailure.fromThrowable(failure)));
        }
    }
}
Also used : TaskStateInternal(org.gradle.api.internal.tasks.TaskStateInternal) DefaultTaskSuccessResult(org.gradle.tooling.internal.provider.events.DefaultTaskSuccessResult) DefaultTaskSkippedResult(org.gradle.tooling.internal.provider.events.DefaultTaskSkippedResult) DefaultTaskFailureResult(org.gradle.tooling.internal.provider.events.DefaultTaskFailureResult)

Aggregations

TaskStateInternal (org.gradle.api.internal.tasks.TaskStateInternal)9 TaskInternal (org.gradle.api.internal.TaskInternal)5 TaskExecutionContext (org.gradle.api.internal.tasks.TaskExecutionContext)4 DefaultTaskOutputs (org.gradle.api.internal.tasks.DefaultTaskOutputs)3 TaskOutputs (org.gradle.api.tasks.TaskOutputs)3 List (java.util.List)2 TaskExecuter (org.gradle.api.internal.tasks.TaskExecuter)2 TaskExecutionOutcome (org.gradle.api.internal.tasks.TaskExecutionOutcome)2 DefaultTaskFailureResult (org.gradle.tooling.internal.provider.events.DefaultTaskFailureResult)2 DefaultTaskSkippedResult (org.gradle.tooling.internal.provider.events.DefaultTaskSkippedResult)2 DefaultTaskSuccessResult (org.gradle.tooling.internal.provider.events.DefaultTaskSuccessResult)2 Expectations (org.jmock.Expectations)2 ImmutableList (com.google.common.collect.ImmutableList)1 Collections.singletonList (java.util.Collections.singletonList)1 Optional (java.util.Optional)1 FileCollectionFactory (org.gradle.api.internal.file.FileCollectionFactory)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 TaskExecuterResult (org.gradle.api.internal.tasks.TaskExecuterResult)1 DefaultTaskExecutionContext (org.gradle.api.internal.tasks.execution.DefaultTaskExecutionContext)1 ExecuteTaskBuildOperationType (org.gradle.api.internal.tasks.execution.ExecuteTaskBuildOperationType)1