use of com.facebook.buck.testutil.FakeProjectFileHashCache in project buck by facebook.
the class RecordingFileHashLoaderTest method testRecordsSymlinkToFileWithinExternalDirectory.
@Test
public void testRecordsSymlinkToFileWithinExternalDirectory() throws IOException {
assumeTrue(!Platform.detect().equals(Platform.WINDOWS));
// Scenario:
// /project/linktoexternaldir/externalfile -> /externalDir/externalfile
// => create link for parent dir: /project/linktoexternaldir -> /externalDir
ProjectFilesystem projectFilesystem = new ProjectFilesystem(projectDir.getRoot().toPath());
externalDir.newFile("externalfile");
Path symlinkRoot = projectDir.getRoot().toPath().resolve("linktoexternaldir");
Files.createSymbolicLink(symlinkRoot, externalDir.getRoot().toPath());
Path symlink = projectFilesystem.relativize(symlinkRoot.resolve(// /project/linktoexternaldir/externalfile
"externalfile"));
RecordedFileHashes recordedFileHashes = new RecordedFileHashes(0);
BuildJobStateFileHashes fileHashes = recordedFileHashes.getRemoteFileHashes();
FakeProjectFileHashCache delegateCache = new FakeProjectFileHashCache(projectFilesystem, ImmutableMap.of(symlink, EXAMPLE_HASHCODE));
RecordingProjectFileHashCache recordingLoader = RecordingProjectFileHashCache.createForCellRoot(delegateCache, recordedFileHashes, new DistBuildConfig(FakeBuckConfig.builder().build()));
recordingLoader.get(symlink);
assertThat(fileHashes.getEntries().size(), Matchers.equalTo(1));
BuildJobStateFileHashEntry fileHashEntry = fileHashes.getEntries().get(0);
assertTrue(fileHashEntry.isSetRootSymLink());
assertThat(fileHashEntry.getRootSymLink(), Matchers.equalTo((unixPath("linktoexternaldir"))));
assertTrue(fileHashEntry.isSetRootSymLink());
assertThat(fileHashEntry.getRootSymLinkTarget(), Matchers.equalTo((unixPath(externalDir.getRoot().toPath().toRealPath().toString()))));
}
use of com.facebook.buck.testutil.FakeProjectFileHashCache in project buck by facebook.
the class RecordingFileHashLoaderTest method testRecordsDirectSymlinkToFile.
@Test
public void testRecordsDirectSymlinkToFile() throws IOException {
// Scenario:
// /project/linktoexternal -> /externalDir/externalfile
// => create direct link: /project/linktoexternal -> /externalDir/externalfile
assumeTrue(!Platform.detect().equals(Platform.WINDOWS));
ProjectFilesystem projectFilesystem = new ProjectFilesystem(projectDir.getRoot().toPath());
Path externalFile = externalDir.newFile("externalfile").toPath();
Path symlinkAbsPath = projectFilesystem.resolve("linktoexternal");
Path symlinkRelPath = projectFilesystem.relativize(symlinkAbsPath);
Files.createSymbolicLink(symlinkAbsPath, externalFile);
RecordedFileHashes recordedFileHashes = new RecordedFileHashes(0);
BuildJobStateFileHashes fileHashes = recordedFileHashes.getRemoteFileHashes();
FakeProjectFileHashCache delegateCache = new FakeProjectFileHashCache(projectFilesystem, ImmutableMap.of(symlinkRelPath, EXAMPLE_HASHCODE));
RecordingProjectFileHashCache recordingLoader = RecordingProjectFileHashCache.createForCellRoot(delegateCache, recordedFileHashes, new DistBuildConfig(FakeBuckConfig.builder().build()));
recordingLoader.get(symlinkRelPath);
assertThat(fileHashes.getEntries().size(), Matchers.equalTo(1));
BuildJobStateFileHashEntry fileHashEntry = fileHashes.getEntries().get(0);
assertTrue(fileHashEntry.isSetRootSymLink());
assertThat(fileHashEntry.getRootSymLink(), Matchers.equalTo((unixPath("linktoexternal"))));
assertTrue(fileHashEntry.isSetRootSymLink());
assertThat(fileHashEntry.getRootSymLinkTarget(), Matchers.equalTo((unixPath(externalFile.toRealPath().toString()))));
}
Aggregations