Search in sources :

Example 16 with PathFragment

use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.

the class RootTest method testAsDerivedRoot.

@Test
public void testAsDerivedRoot() throws IOException {
    Path execRoot = scratch.dir("/exec");
    Path rootDir = scratch.dir("/exec/root");
    Root root = Root.asDerivedRoot(execRoot, rootDir);
    assertFalse(root.isSourceRoot());
    assertEquals(new PathFragment("root"), root.getExecPath());
    assertEquals(rootDir, root.getPath());
    assertEquals("/exec/root[derived]", root.toString());
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 17 with PathFragment

use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.

the class BaseSpawnTest method testGetEnvironmentAddsRunfilesWhenOnlyOneSuppliedViaRunfilesSupplier.

@Test
public void testGetEnvironmentAddsRunfilesWhenOnlyOneSuppliedViaRunfilesSupplier() {
    Map<String, String> baseEnviron = ImmutableMap.of("HELLO", "world");
    final String runfilesDir = "runfilesdir";
    BaseSpawn underTest = minimalBaseSpawn(baseEnviron, new RunfilesSupplierImpl(new PathFragment(runfilesDir), Runfiles.EMPTY));
    Map<String, String> expected = ImmutableMap.<String, String>builder().putAll(baseEnviron).put("PYTHON_RUNFILES", runfilesDir).put("JAVA_RUNFILES", runfilesDir).build();
    assertThat(underTest.getEnvironment()).isEqualTo(expected);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Test(org.junit.Test)

Example 18 with PathFragment

use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.

the class BaseSpawnTest method testGetEnvironmentDoesntAddRunfilesWhenMultipleManifestsSupplied.

@Test
public void testGetEnvironmentDoesntAddRunfilesWhenMultipleManifestsSupplied() {
    Map<String, String> baseEnviron = ImmutableMap.of("HELLO", "world");
    BaseSpawn underTest = minimalBaseSpawn(baseEnviron, new CompositeRunfilesSupplier(new RunfilesSupplierImpl(new PathFragment("rfdir1"), Runfiles.EMPTY), new RunfilesSupplierImpl(new PathFragment("rfdir2"), Runfiles.EMPTY)));
    assertThat(underTest.getEnvironment()).isEqualTo(baseEnviron);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Test(org.junit.Test)

Example 19 with PathFragment

use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.

the class CompositeRunfilesSupplierTest method testGetMappingsReturnsMappingsWithFirstPrecedenceOverSecond.

@Test
public void testGetMappingsReturnsMappingsWithFirstPrecedenceOverSecond() throws IOException {
    PathFragment first = new PathFragment("first");
    Map<PathFragment, Artifact> firstMappings = mkMappings(rootDir, "first1", "first2");
    PathFragment second = new PathFragment("second");
    Map<PathFragment, Artifact> secondMappings = mkMappings(rootDir, "second1", "second2");
    PathFragment shared = new PathFragment("shared");
    Map<PathFragment, Artifact> firstSharedMappings = mkMappings(rootDir, "shared1", "shared2");
    Map<PathFragment, Artifact> secondSharedMappings = mkMappings(rootDir, "lost1", "lost2");
    when(mockFirst.getMappings()).thenReturn(ImmutableMap.of(first, firstMappings, shared, firstSharedMappings));
    when(mockSecond.getMappings()).thenReturn(ImmutableMap.of(second, secondMappings, shared, secondSharedMappings));
    // We expect the mappings for shared added by mockSecond to be dropped.
    CompositeRunfilesSupplier underTest = new CompositeRunfilesSupplier(mockFirst, mockSecond);
    assertThat(underTest.getMappings()).containsExactly(first, firstMappings, second, secondMappings, shared, firstSharedMappings);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Example 20 with PathFragment

use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.

the class CompositeRunfilesSupplierTest method testGetMappingsViaListConstructorReturnsMappingsWithFirstPrecedenceOverSecond.

@Test
public void testGetMappingsViaListConstructorReturnsMappingsWithFirstPrecedenceOverSecond() throws IOException {
    PathFragment first = new PathFragment("first");
    Map<PathFragment, Artifact> firstMappings = mkMappings(rootDir, "first1", "first2");
    PathFragment second = new PathFragment("second");
    Map<PathFragment, Artifact> secondMappings = mkMappings(rootDir, "second1", "second2");
    PathFragment shared = new PathFragment("shared");
    Map<PathFragment, Artifact> firstSharedMappings = mkMappings(rootDir, "shared1", "shared2");
    Map<PathFragment, Artifact> secondSharedMappings = mkMappings(rootDir, "lost1", "lost2");
    when(mockFirst.getMappings()).thenReturn(ImmutableMap.of(first, firstMappings, shared, firstSharedMappings));
    when(mockSecond.getMappings()).thenReturn(ImmutableMap.of(second, secondMappings, shared, secondSharedMappings));
    // We expect the mappings for shared added by mockSecond to be dropped.
    CompositeRunfilesSupplier underTest = new CompositeRunfilesSupplier(ImmutableList.of(mockFirst, mockSecond));
    assertThat(underTest.getMappings()).containsExactly(first, firstMappings, second, secondMappings, shared, firstSharedMappings);
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Test(org.junit.Test)

Aggregations

PathFragment (com.google.devtools.build.lib.vfs.PathFragment)512 Test (org.junit.Test)208 Artifact (com.google.devtools.build.lib.actions.Artifact)184 Path (com.google.devtools.build.lib.vfs.Path)111 RootedPath (com.google.devtools.build.lib.vfs.RootedPath)65 SkyKey (com.google.devtools.build.skyframe.SkyKey)56 IOException (java.io.IOException)38 ArrayList (java.util.ArrayList)35 ImmutableList (com.google.common.collect.ImmutableList)32 Root (com.google.devtools.build.lib.actions.Root)32 HashMap (java.util.HashMap)27 Label (com.google.devtools.build.lib.cmdline.Label)26 LinkedHashMap (java.util.LinkedHashMap)26 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)23 ImmutableMap (com.google.common.collect.ImmutableMap)22 Map (java.util.Map)21 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)20 FilesetTraversalParams (com.google.devtools.build.lib.actions.FilesetTraversalParams)16 PackageIdentifier (com.google.devtools.build.lib.cmdline.PackageIdentifier)16 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)16