use of java.nio.file.FileSystem in project buck by facebook.
the class CellTest method shouldResolveNamesOfCellsAgainstThoseGivenInTheBuckConfig.
@Test
public void shouldResolveNamesOfCellsAgainstThoseGivenInTheBuckConfig() throws IOException, InterruptedException {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
Files.createDirectories(cell2Root);
ProjectFilesystem filesystem1 = new ProjectFilesystem(cell1Root.toAbsolutePath());
ProjectFilesystem filesystem2 = new ProjectFilesystem(cell2Root.toAbsolutePath());
BuckConfig config = FakeBuckConfig.builder().setFilesystem(filesystem1).setSections("[repositories]", "example = " + filesystem2.getRootPath().toString()).build();
Cell cell1 = new TestCellBuilder().setBuckConfig(config).setFilesystem(filesystem1).build();
BuildTarget target = BuildTargetFactory.newInstance(filesystem2, "//does/not:matter");
Cell other = cell1.getCell(target);
assertEquals(cell2Root, other.getFilesystem().getRootPath());
}
use of java.nio.file.FileSystem in project buck by facebook.
the class DefaultCellPathResolverTest method transitiveMappingForDiamond.
@Test
public void transitiveMappingForDiamond() throws Exception {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cellLeftRoot = root.resolve("left");
Files.createDirectories(cellLeftRoot);
Path cellRightRoot = root.resolve("right");
Files.createDirectories(cellRightRoot);
Path cellCenterRoot = root.resolve("center");
Files.createDirectories(cellCenterRoot);
DefaultCellPathResolver cellPathResolver = new DefaultCellPathResolver(cell1Root, ConfigBuilder.createFromText(REPOSITORIES_SECTION, " left = " + cellLeftRoot.toString(), " right = " + cellRightRoot.toString()));
Files.write(cellLeftRoot.resolve(".buckconfig"), ImmutableList.of(REPOSITORIES_SECTION, " center = " + cellCenterRoot.toString()), StandardCharsets.UTF_8);
Files.write(cellRightRoot.resolve(".buckconfig"), ImmutableList.of(REPOSITORIES_SECTION, " center = " + cellCenterRoot.toString()), StandardCharsets.UTF_8);
assertThat(cellPathResolver.getTransitivePathMapping(), Matchers.equalTo(ImmutableMap.<RelativeCellName, Path>builder().put(RelativeCellName.ROOT_CELL_NAME, cell1Root).put(RelativeCellName.of(ImmutableList.of("left")), cellLeftRoot).put(RelativeCellName.of(ImmutableList.of("left", "center")), cellCenterRoot).put(RelativeCellName.of(ImmutableList.of("right", "center")), cellCenterRoot).put(RelativeCellName.of(ImmutableList.of("right")), cellRightRoot).build()));
}
use of java.nio.file.FileSystem in project buck by facebook.
the class DefaultCellPathResolverTest method transtiveMappingForNonexistantCell.
@Test
public void transtiveMappingForNonexistantCell() throws Exception {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
DefaultCellPathResolver cellPathResolver = new DefaultCellPathResolver(cell1Root, ConfigBuilder.createFromText(REPOSITORIES_SECTION, " simple = " + cell2Root.toString()));
// Allow non-existant paths; Buck should allow paths whose .buckconfigs
// cannot be loaded.
assertThat(cellPathResolver.getTransitivePathMapping(), Matchers.equalTo(ImmutableMap.of(RelativeCellName.ROOT_CELL_NAME, cell1Root, RelativeCellName.of(ImmutableList.of("simple")), cell2Root)));
}
use of java.nio.file.FileSystem in project buck by facebook.
the class DefaultCellPathResolverTest method transtiveMappingForSymlinkCycle.
@Test
public void transtiveMappingForSymlinkCycle() throws Exception {
Assume.assumeTrue(Platform.detect() != Platform.WINDOWS);
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
Files.createDirectories(cell2Root);
Path symlinkPath = cell2Root.resolve("symlink");
Files.createSymbolicLink(symlinkPath, cell2Root);
DefaultCellPathResolver cellPathResolver = new DefaultCellPathResolver(cell1Root, ConfigBuilder.createFromText(REPOSITORIES_SECTION, " two = ../repo2"));
Files.write(cell2Root.resolve(".buckconfig"), ImmutableList.of(REPOSITORIES_SECTION, " three = symlink"), StandardCharsets.UTF_8);
assertThat(cellPathResolver.getTransitivePathMapping(), Matchers.equalTo(ImmutableMap.of(RelativeCellName.ROOT_CELL_NAME, cell1Root, RelativeCellName.of(ImmutableList.of("two")), cell2Root)));
}
use of java.nio.file.FileSystem in project buck by facebook.
the class DefaultCellPathResolverTest method knownRulesForSimpleSetup.
@Test
public void knownRulesForSimpleSetup() throws Exception {
FileSystem vfs = Jimfs.newFileSystem(Configuration.unix());
Path root = vfs.getPath("/opt/local/");
Path cell1Root = root.resolve("repo1");
Files.createDirectories(cell1Root);
Path cell2Root = root.resolve("repo2");
Files.createDirectories(cell2Root);
DefaultCellPathResolver cellPathResolver = new DefaultCellPathResolver(cell1Root, ConfigBuilder.createFromText(REPOSITORIES_SECTION, " simple = " + cell2Root.toString()));
assertThat(cellPathResolver.getKnownRoots(), Matchers.containsInAnyOrder(cell1Root, cell2Root));
}
Aggregations