use of com.google.devtools.build.lib.actions.AbstractAction 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);
}
Aggregations