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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations