use of com.google.devtools.build.lib.actions.util.TestAction.DummyAction in project bazel by bazelbuild.
the class TreeArtifactBuildTest method testOneExpandedActionThrowsInActionTemplate.
@Test
public void testOneExpandedActionThrowsInActionTemplate() throws Throwable {
// expect errors
reporter.removeHandler(failFastHandler);
// artifact1 is a tree artifact generated by a TouchingTestAction.
Artifact artifact1 = createTreeArtifact("treeArtifact1");
TreeFileArtifact treeFileArtifactA = ActionInputHelper.treeFileArtifact(artifact1, new PathFragment("child1"));
TreeFileArtifact treeFileArtifactB = ActionInputHelper.treeFileArtifact(artifact1, new PathFragment("child2"));
registerAction(new TouchingTestAction(treeFileArtifactA, treeFileArtifactB));
// artifact2 is a tree artifact generated by an action template.
Artifact artifact2 = createTreeArtifact("treeArtifact2");
SpawnActionTemplate actionTemplate = ActionsTestUtil.createDummySpawnActionTemplate(artifact1, artifact2);
registerAction(actionTemplate);
// We mock out the action template function to expand into two actions:
// One Action that touches the output file.
// The other action that just throws when executed.
TreeFileArtifact expectedOutputTreeFileArtifact1 = ActionInputHelper.treeFileArtifact(artifact2, new PathFragment("child1"));
TreeFileArtifact expectedOutputTreeFileArtifact2 = ActionInputHelper.treeFileArtifact(artifact2, new PathFragment("child2"));
Action generateOutputAction = new DummyAction(ImmutableList.<Artifact>of(treeFileArtifactA), expectedOutputTreeFileArtifact1);
Action throwingAction = new ThrowingDummyAction(ImmutableList.<Artifact>of(treeFileArtifactB), ImmutableList.<Artifact>of(expectedOutputTreeFileArtifact2));
actionTemplateExpansionFunction = new DummyActionTemplateExpansionFunction(ImmutableMultimap.<ActionTemplate<?>, Action>of(actionTemplate, generateOutputAction, actionTemplate, throwingAction));
try {
buildArtifact(artifact2);
fail("Expected BuildFailedException");
} catch (BuildFailedException e) {
assertThat(e.getMessage()).contains("Throwing dummy action");
}
}
use of com.google.devtools.build.lib.actions.util.TestAction.DummyAction in project bazel by bazelbuild.
the class TreeArtifactMetadataTest method createTreeArtifact.
private Artifact createTreeArtifact(String path) throws IOException {
PathFragment execPath = new PathFragment("out").getRelative(path);
Path fullPath = root.getRelative(execPath);
Artifact output = new SpecialArtifact(fullPath, Root.asDerivedRoot(root, root.getRelative("out")), execPath, ALL_OWNER, SpecialArtifactType.TREE);
actions.add(new DummyAction(ImmutableList.<Artifact>of(), output));
FileSystemUtils.createDirectoryAndParents(fullPath);
return output;
}
use of com.google.devtools.build.lib.actions.util.TestAction.DummyAction in project bazel by bazelbuild.
the class ArtifactFunctionTest method createDerivedArtifact.
private Artifact createDerivedArtifact(String path) {
PathFragment execPath = new PathFragment("out").getRelative(path);
Path fullPath = root.getRelative(execPath);
Artifact output = new Artifact(fullPath, Root.asDerivedRoot(root, root.getRelative("out")), execPath, ALL_OWNER);
actions.add(new DummyAction(ImmutableList.<Artifact>of(), output));
return output;
}
use of com.google.devtools.build.lib.actions.util.TestAction.DummyAction in project bazel by bazelbuild.
the class ArtifactFunctionTest method createDerivedTreeArtifactWithAction.
private Artifact createDerivedTreeArtifactWithAction(String path) {
Artifact treeArtifact = createDerivedTreeArtifactOnly(path);
actions.add(new DummyAction(ImmutableList.<Artifact>of(), treeArtifact));
return treeArtifact;
}
use of com.google.devtools.build.lib.actions.util.TestAction.DummyAction in project bazel by bazelbuild.
the class ArtifactFunctionTest method testMiddlemanArtifact.
@Test
public void testMiddlemanArtifact() throws Throwable {
Artifact output = createDerivedArtifact("output");
Artifact input1 = createSourceArtifact("input1");
Artifact input2 = createDerivedArtifact("input2");
Action action = new DummyAction(ImmutableList.of(input1, input2), output, MiddlemanType.AGGREGATING_MIDDLEMAN);
// Overwrite default generating action with this one.
for (Iterator<ActionAnalysisMetadata> it = actions.iterator(); it.hasNext(); ) {
if (it.next().getOutputs().contains(output)) {
it.remove();
break;
}
}
actions.add(action);
file(input2.getPath(), "contents");
file(input1.getPath(), "source contents");
evaluate(Iterables.toArray(ArtifactSkyKey.mandatoryKeys(ImmutableSet.of(input2, input1, input2)), SkyKey.class));
SkyValue value = evaluateArtifactValue(output);
assertThat(((AggregatingArtifactValue) value).getInputs()).containsExactly(Pair.of(input1, create(input1)), Pair.of(input2, create(input2)));
}
Aggregations