use of com.google.devtools.build.lib.actions.ActionInputFileCache in project bazel by bazelbuild.
the class TreeArtifactBuildTest method testInputTreeArtifactPerActionFileCache.
@Test
public void testInputTreeArtifactPerActionFileCache() throws Exception {
TouchingTestAction actionOne = new TouchingTestAction(outOneFileOne, outOneFileTwo);
registerAction(actionOne);
final Artifact normalOutput = createDerivedArtifact("normal/out");
Action testAction = new TestAction(TestAction.NO_EFFECT, ImmutableList.of(outOne), ImmutableList.of(normalOutput)) {
@Override
public void execute(ActionExecutionContext actionExecutionContext) {
try {
// Check the file cache for input TreeFileArtifacts.
ActionInputFileCache fileCache = actionExecutionContext.getActionInputFileCache();
assertThat(fileCache.getDigest(outOneFileOne)).isNotNull();
assertThat(fileCache.getDigest(outOneFileTwo)).isNotNull();
// Touch the action output.
touchFile(normalOutput);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
registerAction(testAction);
buildArtifact(normalOutput);
}
use of com.google.devtools.build.lib.actions.ActionInputFileCache in project bazel by bazelbuild.
the class SpawnInputExpanderTest method testRunfilesSymlink.
@Test
public void testRunfilesSymlink() throws Exception {
Artifact artifact = new Artifact(fs.getPath("/root/dir/file"), Root.asSourceRoot(fs.getPath("/root")));
Runfiles runfiles = new Runfiles.Builder("workspace").addSymlink(new PathFragment("symlink"), artifact).build();
RunfilesSupplier supplier = new RunfilesSupplierImpl(new PathFragment("runfiles"), runfiles);
ActionInputFileCache mockCache = Mockito.mock(ActionInputFileCache.class);
Mockito.when(mockCache.isFile(artifact)).thenReturn(true);
expander.addRunfilesToInputs(inputMappings, supplier, mockCache);
assertThat(inputMappings).hasSize(1);
assertThat(inputMappings).containsEntry(new PathFragment("runfiles/workspace/symlink"), artifact);
}
use of com.google.devtools.build.lib.actions.ActionInputFileCache in project bazel by bazelbuild.
the class SpawnInputExpanderTest method testRunfilesRootSymlink.
@Test
public void testRunfilesRootSymlink() throws Exception {
Artifact artifact = new Artifact(fs.getPath("/root/dir/file"), Root.asSourceRoot(fs.getPath("/root")));
Runfiles runfiles = new Runfiles.Builder("workspace").addRootSymlink(new PathFragment("symlink"), artifact).build();
RunfilesSupplier supplier = new RunfilesSupplierImpl(new PathFragment("runfiles"), runfiles);
ActionInputFileCache mockCache = Mockito.mock(ActionInputFileCache.class);
Mockito.when(mockCache.isFile(artifact)).thenReturn(true);
expander.addRunfilesToInputs(inputMappings, supplier, mockCache);
assertThat(inputMappings).hasSize(2);
assertThat(inputMappings).containsEntry(new PathFragment("runfiles/symlink"), artifact);
// If there's no other entry, Runfiles adds an empty file in the workspace to make sure the
// directory gets created.
assertThat(inputMappings).containsEntry(new PathFragment("runfiles/workspace/.runfile"), SpawnInputExpander.EMPTY_FILE);
}
use of com.google.devtools.build.lib.actions.ActionInputFileCache in project bazel by bazelbuild.
the class SpawnInputExpanderTest method testRunfilesDirectoryNonStrict.
@Test
public void testRunfilesDirectoryNonStrict() throws Exception {
Artifact artifact = new Artifact(fs.getPath("/root/dir/file"), Root.asSourceRoot(fs.getPath("/root")));
Runfiles runfiles = new Runfiles.Builder("workspace").addArtifact(artifact).build();
RunfilesSupplier supplier = new RunfilesSupplierImpl(new PathFragment("runfiles"), runfiles);
ActionInputFileCache mockCache = Mockito.mock(ActionInputFileCache.class);
Mockito.when(mockCache.isFile(artifact)).thenReturn(false);
expander = new SpawnInputExpander(/*strict=*/
false);
expander.addRunfilesToInputs(inputMappings, supplier, mockCache);
assertThat(inputMappings).hasSize(1);
assertThat(inputMappings).containsEntry(new PathFragment("runfiles/workspace/dir/file"), artifact);
}
use of com.google.devtools.build.lib.actions.ActionInputFileCache in project bazel by bazelbuild.
the class SpawnInputExpanderTest method testRunfilesDirectoryStrict.
@Test
public void testRunfilesDirectoryStrict() throws Exception {
Artifact artifact = new Artifact(fs.getPath("/root/dir/file"), Root.asSourceRoot(fs.getPath("/root")));
Runfiles runfiles = new Runfiles.Builder("workspace").addArtifact(artifact).build();
RunfilesSupplier supplier = new RunfilesSupplierImpl(new PathFragment("runfiles"), runfiles);
ActionInputFileCache mockCache = Mockito.mock(ActionInputFileCache.class);
Mockito.when(mockCache.isFile(artifact)).thenReturn(false);
try {
expander.addRunfilesToInputs(inputMappings, supplier, mockCache);
fail();
} catch (IOException expected) {
assertThat(expected.getMessage().contains("Not a file: /root/dir/file")).isTrue();
}
}
Aggregations