Search in sources :

Example 11 with ArchiveMemberPath

use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.

the class StackedFileHashCacheTest method usesSecondCacheForArchivePathAbsolutePath.

@Test
public void usesSecondCacheForArchivePathAbsolutePath() throws IOException {
    Path path = Paths.get("world.jar");
    Path fullPath = tmp2.getRoot().resolve(path);
    ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(new ProjectFilesystem(tmp.getRoot()));
    // The second project filesystem has the file.
    ProjectFilesystem filesystem2 = new ProjectFilesystem(tmp2.getRoot());
    ProjectFileHashCache innerCache2 = DefaultFileHashCache.createDefaultFileHashCache(filesystem2);
    writeJarWithHashes(filesystem2, fullPath);
    ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(path, Paths.get(SOME_FILE_INSIDE_JAR));
    ArchiveMemberPath fullArchiveMemberPath = archiveMemberPath.withArchivePath(filesystem2.resolve(archiveMemberPath.getArchivePath()));
    StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache, innerCache2));
    cache.get(fullArchiveMemberPath);
    assertTrue(innerCache2.willGet(archiveMemberPath));
}
Also used : ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Path(java.nio.file.Path) ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 12 with ArchiveMemberPath

use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.

the class StackedFileHashCacheTest method usesSecondCacheForArchivePath.

@Test
public void usesSecondCacheForArchivePath() throws IOException {
    ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(new ProjectFilesystem(tmp.getRoot()));
    // The second project filesystem has the file.
    ProjectFilesystem filesystem2 = new ProjectFilesystem(tmp2.getRoot());
    Path path = filesystem2.getPath("world.jar");
    ProjectFileHashCache innerCache2 = DefaultFileHashCache.createDefaultFileHashCache(filesystem2);
    writeJarWithHashes(filesystem2, path);
    ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(path, Paths.get(SOME_FILE_INSIDE_JAR));
    StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache, innerCache2));
    cache.get(filesystem2, archiveMemberPath);
    assertTrue(innerCache2.willGet(archiveMemberPath));
}
Also used : ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Path(java.nio.file.Path) ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 13 with ArchiveMemberPath

use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.

the class StackedFileHashCacheTest method skipsFirstCacheBecauseIgnoredForArchiveMemberPathAbsolutePath.

@Test
public void skipsFirstCacheBecauseIgnoredForArchiveMemberPathAbsolutePath() throws IOException {
    Config config = ConfigBuilder.createFromText("[project]", "ignore = world.jar");
    Path fullPath = Paths.get("world.jar");
    ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot(), config);
    writeJarWithHashes(filesystem, filesystem.resolve(fullPath));
    ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(filesystem.resolve(fullPath), Paths.get("Nonexistent.class"));
    ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(filesystem);
    StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
    expectedException.expect(NoSuchFileException.class);
    cache.get(archiveMemberPath);
}
Also used : ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Path(java.nio.file.Path) ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Config(com.facebook.buck.config.Config) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 14 with ArchiveMemberPath

use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.

the class StackedFileHashCacheTest method usesFirstCacheForArchivePathAbsolutePath.

@Test
public void usesFirstCacheForArchivePathAbsolutePath() throws IOException {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();
    Path path = Paths.get("world.jar");
    writeJarWithHashes(filesystem, path);
    ArchiveMemberPath archiveMemberPath = ArchiveMemberPath.of(path, Paths.get(SOME_FILE_INSIDE_JAR));
    ArchiveMemberPath fullArchiveMemberPath = archiveMemberPath.withArchivePath(filesystem.resolve(archiveMemberPath.getArchivePath()));
    ProjectFileHashCache innerCache = DefaultFileHashCache.createDefaultFileHashCache(filesystem);
    StackedFileHashCache cache = new StackedFileHashCache(ImmutableList.of(innerCache));
    cache.get(fullArchiveMemberPath);
    assertTrue(innerCache.willGet(archiveMemberPath));
}
Also used : ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Path(java.nio.file.Path) ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 15 with ArchiveMemberPath

use of com.facebook.buck.io.ArchiveMemberPath in project buck by facebook.

the class StackedFileHashCacheTest method skipsFirstCacheForArchiveMemberPath.

@Test
public void skipsFirstCacheForArchiveMemberPath() throws IOException {
    ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
    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);
}
Also used : ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) Path(java.nio.file.Path) ArchiveMemberPath(com.facebook.buck.io.ArchiveMemberPath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Aggregations

ArchiveMemberPath (com.facebook.buck.io.ArchiveMemberPath)16 Path (java.nio.file.Path)14 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)11 Test (org.junit.Test)11 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)10 Config (com.facebook.buck.config.Config)2 BuildJobStateFileHashes (com.facebook.buck.distributed.thrift.BuildJobStateFileHashes)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 ArchiveMemberSourcePath (com.facebook.buck.rules.ArchiveMemberSourcePath)1 DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)1 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)1 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)1 FileHashCache (com.facebook.buck.util.cache.FileHashCache)1 NullFileHashCache (com.facebook.buck.util.cache.NullFileHashCache)1 ProjectFileHashCache (com.facebook.buck.util.cache.ProjectFileHashCache)1 StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)1 HashCode (com.google.common.hash.HashCode)1 IOException (java.io.IOException)1 NoSuchFileException (java.nio.file.NoSuchFileException)1 ExecutionException (java.util.concurrent.ExecutionException)1