use of com.facebook.buck.io.ProjectFilesystemDelegate in project buck by facebook.
the class EdenProjectFilesystemDelegateTest method computeSha1ForSymlinkUnderMountThatPointsToFileUnderMount.
@Test
public void computeSha1ForSymlinkUnderMountThatPointsToFileUnderMount() throws EdenError, TException, IOException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
// Create a symlink within the project root.
Path link = fs.getPath("/work/link");
Path target = fs.getPath("/work/target");
Files.createFile(target);
Files.createSymbolicLink(link, target);
// Eden will throw when the SHA-1 for the link is requested, but return a SHA-1 when the target
// is requested.
EdenMount mount = createMock(EdenMount.class);
expect(mount.getBindMounts()).andReturn(ImmutableList.of());
expect(mount.getPathRelativeToProjectRoot(link)).andReturn(Optional.of(fs.getPath("link")));
expect(mount.getPathRelativeToProjectRoot(target)).andReturn(Optional.of(fs.getPath("target")));
expect(mount.getSha1(fs.getPath("link"))).andThrow(new EdenError());
expect(mount.getSha1(fs.getPath("target"))).andReturn(DUMMY_SHA1);
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals(DUMMY_SHA1, edenDelegate.computeSha1(link));
verify(mount);
}
use of com.facebook.buck.io.ProjectFilesystemDelegate in project buck by facebook.
the class EdenProjectFilesystemDelegateTest method computeSha1ForSymlinkUnderMountThatPointsToFileOutsideMount.
@Test
public void computeSha1ForSymlinkUnderMountThatPointsToFileOutsideMount() throws IOException, EdenError, TException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path root = fs.getPath(JIMFS_WORKING_DIRECTORY);
ProjectFilesystemDelegate delegate = new DefaultProjectFilesystemDelegate(root);
// Create a symlink within the project root.
Path link = fs.getPath("/work/link");
Path target = fs.getPath("/example");
Files.createFile(target);
byte[] bytes = new byte[] { 66, 85, 67, 75 };
Files.write(target, bytes);
Files.createSymbolicLink(link, target);
// Eden will throw when the SHA-1 for the link is requested, but return a SHA-1 when the target
// is requested.
EdenMount mount = createMock(EdenMount.class);
expect(mount.getBindMounts()).andReturn(ImmutableList.of());
expect(mount.getPathRelativeToProjectRoot(link)).andReturn(Optional.of(fs.getPath("link")));
expect(mount.getPathRelativeToProjectRoot(target)).andReturn(Optional.empty());
expect(mount.getSha1(fs.getPath("link"))).andThrow(new EdenError());
replay(mount);
EdenProjectFilesystemDelegate edenDelegate = new EdenProjectFilesystemDelegate(mount, delegate);
assertEquals("EdenProjectFilesystemDelegate.computeSha1() should return the SHA-1 of the target of " + "the symlink even though the target is outside of the EdenFS root.", Sha1HashCode.fromHashCode(Hashing.sha1().hashBytes(bytes)), edenDelegate.computeSha1(link));
verify(mount);
}
use of com.facebook.buck.io.ProjectFilesystemDelegate in project buck by facebook.
the class AutoSparseIntegrationTest method testSymlinkNotExisting.
@Test
public void testSymlinkNotExisting() {
ProjectFilesystemDelegate delegate = createDelegate();
Assume.assumeFalse(delegate.isSymlink(repoPath.resolve("nonsuch")));
}
use of com.facebook.buck.io.ProjectFilesystemDelegate in project buck by facebook.
the class AutoSparseIntegrationTest method testNotExists.
@Test
public void testNotExists() {
ProjectFilesystemDelegate delegate = createDelegate();
Assume.assumeFalse(delegate.exists(repoPath.resolve("nonsuch")));
}
use of com.facebook.buck.io.ProjectFilesystemDelegate in project buck by facebook.
the class AutoSparseIntegrationTest method testAutosparseDisabled.
@Test
public void testAutosparseDisabled() {
ProjectFilesystemDelegate delegate = createDelegate(repoPath, false, ImmutableList.of());
Assume.assumeFalse(delegate instanceof AutoSparseProjectFilesystemDelegate);
}
Aggregations