Search in sources :

Example 6 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl 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 7 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl 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)

Example 8 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl 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 9 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl 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 10 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl 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)

Aggregations

RunfilesSupplierImpl (com.google.devtools.build.lib.analysis.RunfilesSupplierImpl)12 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)11 Test (org.junit.Test)10 Artifact (com.google.devtools.build.lib.actions.Artifact)9 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)7 ActionInputFileCache (com.google.devtools.build.lib.actions.ActionInputFileCache)6 EmptyRunfilesSupplier (com.google.devtools.build.lib.actions.EmptyRunfilesSupplier)6 RunfilesSupplier (com.google.devtools.build.lib.actions.RunfilesSupplier)6 AbstractAction (com.google.devtools.build.lib.actions.AbstractAction)2 Action (com.google.devtools.build.lib.actions.Action)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 EnvironmentalExecException (com.google.devtools.build.lib.actions.EnvironmentalExecException)1 Executor (com.google.devtools.build.lib.actions.Executor)1 SimpleSpawn (com.google.devtools.build.lib.actions.SimpleSpawn)1 Spawn (com.google.devtools.build.lib.actions.Spawn)1 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)1 ActionCombinationFactory (com.google.devtools.build.lib.analysis.util.ActionTester.ActionCombinationFactory)1