use of com.google.devtools.build.lib.actions.ActionExecutionContext in project bazel by bazelbuild.
the class ParamFileWriteActionTest method testWriteCommandLineWithoutTreeArtifactExpansion.
@Test
public void testWriteCommandLineWithoutTreeArtifactExpansion() throws Exception {
Action action = createParameterFileWriteAction(ImmutableList.<Artifact>of(), createNormalCommandLine());
ActionExecutionContext context = actionExecutionContext();
action.execute(context);
String content = new String(FileSystemUtils.readContentAsLatin1(outputArtifact.getPath()));
assertEquals("--flag1\n--flag2\n--flag3\nvalue1\nvalue2", content.trim());
}
use of com.google.devtools.build.lib.actions.ActionExecutionContext in project bazel by bazelbuild.
the class ParamFileWriteActionTest method testWriteCommandLineWithTreeArtifactExpansion.
@Test
public void testWriteCommandLineWithTreeArtifactExpansion() throws Exception {
Action action = createParameterFileWriteAction(ImmutableList.of(treeArtifact), createTreeArtifactExpansionCommandLine());
ActionExecutionContext context = actionExecutionContext();
action.execute(context);
String content = new String(FileSystemUtils.readContentAsLatin1(outputArtifact.getPath()));
assertEquals("--flag1\n" + "artifact/myTreeFileArtifact/artifacts/treeFileArtifact1:" + "artifact/myTreeFileArtifact/artifacts/treeFileArtifact2", content.trim());
}
use of com.google.devtools.build.lib.actions.ActionExecutionContext in project bazel by bazelbuild.
the class ParamFileWriteActionTest method actionExecutionContext.
private ActionExecutionContext actionExecutionContext() throws Exception {
final Iterable<TreeFileArtifact> treeFileArtifacts = ImmutableList.of(createTreeFileArtifact(treeArtifact, "artifacts/treeFileArtifact1"), createTreeFileArtifact(treeArtifact, "artifacts/treeFileArtifact2"));
ArtifactExpander artifactExpander = new ArtifactExpander() {
@Override
public void expand(Artifact artifact, Collection<? super Artifact> output) {
for (TreeFileArtifact treeFileArtifact : treeFileArtifacts) {
if (treeFileArtifact.getParent().equals(artifact)) {
output.add(treeFileArtifact);
}
}
}
};
Executor executor = new TestExecutorBuilder(directories, binTools).build();
return new ActionExecutionContext(executor, null, null, new FileOutErr(), ImmutableMap.<String, String>of(), artifactExpander);
}
use of com.google.devtools.build.lib.actions.ActionExecutionContext in project bazel by bazelbuild.
the class PopulateTreeArtifactActionTest method testTreeFileArtifactPathPrefixConflicts.
@Test
public void testTreeFileArtifactPathPrefixConflicts() throws Exception {
Action action = createPopulateTreeArtifactAction();
scratch.overwriteFile("archiveManifest.txt", "archive_members/conflict", "archive_members/conflict/1.class");
ActionExecutionContext executionContext = actionExecutionContext(new ArrayList<Artifact>());
try {
action.execute(executionContext);
fail("Artifact path prefix conflicts, expected exception");
} catch (ActionExecutionException e) {
// Expect ActionExecutionException
}
}
use of com.google.devtools.build.lib.actions.ActionExecutionContext in project bazel by bazelbuild.
the class PopulateTreeArtifactActionTest method testOutputTreeFileArtifactDirsCreated.
@Test
public void testOutputTreeFileArtifactDirsCreated() throws Exception {
Action action = createPopulateTreeArtifactAction();
scratch.overwriteFile("archiveManifest.txt", "archive_members/dirA/memberA", "archive_members/dirB/memberB");
ArrayList<Artifact> treeFileArtifacts = new ArrayList<Artifact>();
ActionExecutionContext executionContext = actionExecutionContext(treeFileArtifacts);
action.execute(executionContext);
// We check whether the parent directory structures of output TreeFileArtifacts exist even
// though the spawn is not executed (the SpawnActionContext is mocked out).
assertThat(treeFileArtifacts).hasSize(2);
for (Artifact treeFileArtifact : treeFileArtifacts) {
assertThat(treeFileArtifact.getPath().getParentDirectory().exists()).isTrue();
assertThat(treeFileArtifact.getPath().exists()).isFalse();
}
}
Aggregations