Search in sources :

Example 26 with ActionExecutionException

use of com.google.devtools.build.lib.actions.ActionExecutionException in project bazel by bazelbuild.

the class ActionDataTest method testArgumentToBuildArtifactsIsPassedDownToAction.

@Test
public void testArgumentToBuildArtifactsIsPassedDownToAction() throws Exception {
    class MyAction extends AbstractAction {

        Object executor = null;

        public MyAction(Collection<Artifact> outputs) {
            super(ActionsTestUtil.NULL_ACTION_OWNER, ImmutableList.<Artifact>of(), outputs);
        }

        @Override
        public void execute(ActionExecutionContext actionExecutionContext) throws ActionExecutionException {
            this.executor = actionExecutionContext.getExecutor();
            try {
                FileSystemUtils.createEmptyFile(getPrimaryOutput().getPath());
            } catch (IOException e) {
                throw new ActionExecutionException("failed: ", e, this, false);
            }
        }

        @Override
        protected String computeKey() {
            return "MyAction";
        }

        @Override
        public String getMnemonic() {
            return "MyAction";
        }
    }
    Artifact output = createDerivedArtifact("foo");
    Set<Artifact> outputs = Sets.newHashSet(output);
    MyAction action = new MyAction(outputs);
    registerAction(action);
    Executor executor = new DummyExecutor(scratch.dir("/"));
    amnesiacBuilder().buildArtifacts(reporter, outputs, null, null, null, null, executor, null, /*explain=*/
    false, null, null);
    assertSame(executor, action.executor);
    executor = new DummyExecutor(scratch.dir("/"));
    amnesiacBuilder().buildArtifacts(reporter, outputs, null, null, null, null, executor, null, /*explain=*/
    false, null, null);
    assertSame(executor, action.executor);
}
Also used : DummyExecutor(com.google.devtools.build.lib.actions.util.DummyExecutor) Executor(com.google.devtools.build.lib.actions.Executor) DummyExecutor(com.google.devtools.build.lib.actions.util.DummyExecutor) ActionExecutionContext(com.google.devtools.build.lib.actions.ActionExecutionContext) Collection(java.util.Collection) IOException(java.io.IOException) ActionExecutionException(com.google.devtools.build.lib.actions.ActionExecutionException) AbstractAction(com.google.devtools.build.lib.actions.AbstractAction) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Aggregations

ActionExecutionException (com.google.devtools.build.lib.actions.ActionExecutionException)26 Artifact (com.google.devtools.build.lib.actions.Artifact)15 IOException (java.io.IOException)14 ActionExecutionContext (com.google.devtools.build.lib.actions.ActionExecutionContext)6 AlreadyReportedActionExecutionException (com.google.devtools.build.lib.actions.AlreadyReportedActionExecutionException)6 Path (com.google.devtools.build.lib.vfs.Path)5 Map (java.util.Map)5 Test (org.junit.Test)5 Action (com.google.devtools.build.lib.actions.Action)4 BuildFailedException (com.google.devtools.build.lib.actions.BuildFailedException)4 Executor (com.google.devtools.build.lib.actions.Executor)4 MissingInputFileException (com.google.devtools.build.lib.actions.MissingInputFileException)4 SkyKey (com.google.devtools.build.skyframe.SkyKey)4 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)3 ExecException (com.google.devtools.build.lib.actions.ExecException)3 ThreadCompatible (com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadCompatible)3 ValueOrException2 (com.google.devtools.build.skyframe.ValueOrException2)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)2 ArtifactPrefixConflictException (com.google.devtools.build.lib.actions.ArtifactPrefixConflictException)2