Search in sources :

Example 1 with RunfilesSupplier

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

the class SkylarkRuleImplementationFunctionsTest method testResolveCommandInputs.

@Test
public void testResolveCommandInputs() throws Exception {
    evalRuleContextCode(createRuleContext("//foo:resolve_me"), "inputs, argv, input_manifests = ruleContext.resolve_command(", "   tools=ruleContext.attr.tools)");
    @SuppressWarnings("unchecked") List<Artifact> inputs = (List<Artifact>) (List<?>) (MutableList) lookup("inputs");
    assertArtifactFilenames(inputs, "mytool.sh", "mytool", "foo_Smytool-runfiles", "t.exe");
    @SuppressWarnings("unchecked") CompositeRunfilesSupplier runfilesSupplier = new CompositeRunfilesSupplier((List<RunfilesSupplier>) lookup("input_manifests"));
    assertThat(runfilesSupplier.getMappings()).hasSize(1);
}
Also used : CompositeRunfilesSupplier(com.google.devtools.build.lib.actions.CompositeRunfilesSupplier) MutableList(com.google.devtools.build.lib.syntax.SkylarkList.MutableList) MutableList(com.google.devtools.build.lib.syntax.SkylarkList.MutableList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Artifact(com.google.devtools.build.lib.actions.Artifact) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) CompositeRunfilesSupplier(com.google.devtools.build.lib.actions.CompositeRunfilesSupplier) Test(org.junit.Test)

Example 2 with RunfilesSupplier

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

the class RunfilesSupplierImplTest method testGetArtifactsFilterMiddlemen.

@Test
public void testGetArtifactsFilterMiddlemen() {
    List<Artifact> artifacts = mkArtifacts(rootDir, "thing1", "thing2");
    Artifact middleman = new Artifact(new PathFragment("middleman"), middlemanRoot);
    Runfiles runfiles = mkRunfiles(Iterables.concat(artifacts, ImmutableList.of(middleman)));
    RunfilesSupplier underTest = new RunfilesSupplierImpl(new PathFragment("notimportant"), runfiles);
    assertThat(underTest.getArtifacts()).containsExactlyElementsIn(artifacts);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Artifact(com.google.devtools.build.lib.actions.Artifact) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) Test(org.junit.Test)

Example 3 with RunfilesSupplier

use of com.google.devtools.build.lib.actions.RunfilesSupplier 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);
}
Also used : Runfiles(com.google.devtools.build.lib.analysis.Runfiles) ActionInputFileCache(com.google.devtools.build.lib.actions.ActionInputFileCache) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Artifact(com.google.devtools.build.lib.actions.Artifact) EmptyRunfilesSupplier(com.google.devtools.build.lib.actions.EmptyRunfilesSupplier) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) Test(org.junit.Test)

Example 4 with RunfilesSupplier

use of com.google.devtools.build.lib.actions.RunfilesSupplier 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);
}
Also used : Runfiles(com.google.devtools.build.lib.analysis.Runfiles) ActionInputFileCache(com.google.devtools.build.lib.actions.ActionInputFileCache) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Artifact(com.google.devtools.build.lib.actions.Artifact) EmptyRunfilesSupplier(com.google.devtools.build.lib.actions.EmptyRunfilesSupplier) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) Test(org.junit.Test)

Example 5 with RunfilesSupplier

use of com.google.devtools.build.lib.actions.RunfilesSupplier 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);
}
Also used : Runfiles(com.google.devtools.build.lib.analysis.Runfiles) ActionInputFileCache(com.google.devtools.build.lib.actions.ActionInputFileCache) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Artifact(com.google.devtools.build.lib.actions.Artifact) EmptyRunfilesSupplier(com.google.devtools.build.lib.actions.EmptyRunfilesSupplier) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) Test(org.junit.Test)

Aggregations

RunfilesSupplier (com.google.devtools.build.lib.actions.RunfilesSupplier)11 Test (org.junit.Test)11 Artifact (com.google.devtools.build.lib.actions.Artifact)9 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)9 EmptyRunfilesSupplier (com.google.devtools.build.lib.actions.EmptyRunfilesSupplier)7 ActionInputFileCache (com.google.devtools.build.lib.actions.ActionInputFileCache)6 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)6 RunfilesSupplierImpl (com.google.devtools.build.lib.analysis.RunfilesSupplierImpl)6 ImmutableList (com.google.common.collect.ImmutableList)1 CompositeRunfilesSupplier (com.google.devtools.build.lib.actions.CompositeRunfilesSupplier)1 MutableList (com.google.devtools.build.lib.syntax.SkylarkList.MutableList)1 IOException (java.io.IOException)1 List (java.util.List)1