use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.
the class SourcePathResolver method getAbsoluteArchiveMemberPath.
public ArchiveMemberPath getAbsoluteArchiveMemberPath(SourcePath sourcePath) {
Preconditions.checkState(sourcePath instanceof ArchiveMemberSourcePath);
ArchiveMemberSourcePath archiveMemberSourcePath = (ArchiveMemberSourcePath) sourcePath;
Path archiveAbsolutePath = getAbsolutePath(archiveMemberSourcePath.getArchiveSourcePath());
return ArchiveMemberPath.of(archiveAbsolutePath, archiveMemberSourcePath.getMemberPath());
}
use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.
the class DistBuildFileHashesTest method readsHashesForArchiveMembers.
@Test
public void readsHashesForArchiveMembers() throws Exception {
try (ArchiveFilesFixture f = ArchiveFilesFixture.create(archiveTempDir)) {
List<BuildJobStateFileHashes> recordedHashes = f.distributedBuildFileHashes.getFileHashes();
ProjectFilesystem readProjectFilesystem = new ProjectFilesystem(tempDir.newFolder("read_hashes").toPath().toRealPath());
ProjectFileHashCache mockCache = EasyMock.createMock(ProjectFileHashCache.class);
EasyMock.expect(mockCache.getFilesystem()).andReturn(readProjectFilesystem).anyTimes();
EasyMock.replay(mockCache);
ProjectFileHashCache fileHashCache = DistBuildFileHashes.createFileHashCache(mockCache, recordedHashes.get(0));
ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(readProjectFilesystem.resolve(f.archivePath), f.archiveMemberPath);
assertThat(fileHashCache.willGet(archiveMemberPath), Matchers.is(true));
assertThat(fileHashCache.get(archiveMemberPath), Matchers.is(f.archiveMemberHash));
}
}
use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.
the class SourcePathResolverTest method testGetAbsolutePathForArchiveMemberSourcePath.
@Test
public void testGetAbsolutePathForArchiveMemberSourcePath() {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
BuildRule rule = resolver.addToIndex(new FakeBuildRule(BuildTargetFactory.newInstance("//foo:bar"), filesystem, pathResolver));
Path archivePath = filesystem.getBuckPaths().getGenDir().resolve("foo.jar");
Path archiveAbsolutePath = filesystem.resolve(archivePath);
SourcePath archiveSourcePath = new ExplicitBuildTargetSourcePath(rule.getBuildTarget(), archivePath);
Path memberPath = Paths.get("foo.class");
ArchiveMemberSourcePath path = new ArchiveMemberSourcePath(archiveSourcePath, memberPath);
ArchiveMemberPath absolutePath = pathResolver.getAbsoluteArchiveMemberPath(path);
assertEquals(archiveAbsolutePath, absolutePath.getArchivePath());
assertEquals(memberPath, absolutePath.getMemberPath());
}
use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.
the class StackedFileHashCacheTest method skipsFirstCacheBecauseIgnoredForArchiveMemberPath.
@Test
public void skipsFirstCacheBecauseIgnoredForArchiveMemberPath() throws IOException {
Config config = ConfigBuilder.createFromText("[project]", "ignore = world.jar");
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot(), config);
Path path = filesystem.getPath("world.jar");
writeJarWithHashes(filesystem, path);
ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(path, filesystem.getPath("Nonexistent.class"));
ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(filesystem);
StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
expectedException.expect(NoSuchFileException.class);
cache.get(filesystem, archiveMemberPath);
}
use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.
the class StackedFileHashCacheTest method usesFirstCacheForArchivePath.
@Test
public void usesFirstCacheForArchivePath() throws IOException {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
Path path = filesystem.getPath("world.jar");
writeJarWithHashes(filesystem, path);
ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(path, Paths.get(SOME_FILE_INSIDE_JAR));
ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(filesystem);
StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
cache.get(filesystem, archiveMemberPath);
assertTrue(innerCache.willGet(archiveMemberPath));
}
Aggregations