Search in sources :

Example 6 with RunfilesSupplier

use of com.google.devtools.build.lib.actions.RunfilesSupplier 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();
    }
}
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) IOException(java.io.IOException) 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 7 with RunfilesSupplier

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

the class SpawnInputExpanderTest method testEmptyRunfiles.

@Test
public void testEmptyRunfiles() throws Exception {
    RunfilesSupplier supplier = EmptyRunfilesSupplier.INSTANCE;
    expander.addRunfilesToInputs(inputMappings, supplier, null);
    assertThat(inputMappings).isEmpty();
}
Also used : EmptyRunfilesSupplier(com.google.devtools.build.lib.actions.EmptyRunfilesSupplier) RunfilesSupplier(com.google.devtools.build.lib.actions.RunfilesSupplier) Test(org.junit.Test)

Example 8 with RunfilesSupplier

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

the class SpawnInputExpanderTest method testRunfilesTwoFiles.

@Test
public void testRunfilesTwoFiles() throws Exception {
    Artifact artifact1 = new Artifact(fs.getPath("/root/dir/file"), Root.asSourceRoot(fs.getPath("/root")));
    Artifact artifact2 = new Artifact(fs.getPath("/root/dir/baz"), Root.asSourceRoot(fs.getPath("/root")));
    Runfiles runfiles = new Runfiles.Builder("workspace").addArtifact(artifact1).addArtifact(artifact2).build();
    RunfilesSupplier supplier = new RunfilesSupplierImpl(new PathFragment("runfiles"), runfiles);
    ActionInputFileCache mockCache = Mockito.mock(ActionInputFileCache.class);
    Mockito.when(mockCache.isFile(artifact1)).thenReturn(true);
    Mockito.when(mockCache.isFile(artifact2)).thenReturn(true);
    expander.addRunfilesToInputs(inputMappings, supplier, mockCache);
    assertThat(inputMappings).hasSize(2);
    assertThat(inputMappings).containsEntry(new PathFragment("runfiles/workspace/dir/file"), artifact1);
    assertThat(inputMappings).containsEntry(new PathFragment("runfiles/workspace/dir/baz"), artifact2);
}
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 9 with RunfilesSupplier

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

the class SpawnInputExpanderTest method testRunfilesSingleFile.

@Test
public void testRunfilesSingleFile() 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(true);
    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)

Example 10 with RunfilesSupplier

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

the class RunfilesSupplierImplTest method testGetManifestsWhenNone.

@Test
public void testGetManifestsWhenNone() {
    RunfilesSupplier underTest = new RunfilesSupplierImpl(new PathFragment("ignored"), Runfiles.EMPTY, null);
    assertThat(underTest.getManifests()).isEmpty();
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) 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