use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testStringArtifactsAreCached.
@Test
public void testStringArtifactsAreCached() throws IOException {
Assume.assumeFalse(true);
workspace.enableDirCache();
workspace.runBuckBuild("//apps/sample:app_comp_str").assertSuccess();
BuckBuildLog buildLog = workspace.getBuildLog();
Sha1HashCode androidBinaryRuleKey = buildLog.getRuleKey("//apps/sample:app_comp_str");
ArtifactCache cache = TestArtifactCaches.createDirCacheForTest(workspace.getPath("."), filesystem.getBuckPaths().getCacheDir());
Path cachedFile = DirArtifactCacheTestUtil.getPathForRuleKey(cache, new RuleKey(androidBinaryRuleKey.getHash()), Optional.empty());
Files.delete(workspace.resolve(cachedFile));
workspace.runBuckCommand("clean").assertSuccess();
workspace.runBuckBuild("//apps/sample:app_comp_str").assertSuccess();
}
use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class AuditInputCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
console = new TestConsole();
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
projectFilesystem.touch(Paths.get("src/com/facebook/AndroidLibraryTwo.java"));
projectFilesystem.touch(Paths.get("src/com/facebook/TestAndroidLibrary.java"));
projectFilesystem.touch(Paths.get("src/com/facebook/TestJavaLibrary.java"));
Cell cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
auditInputCommand = new AuditInputCommand();
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, new FakeAndroidDirectoryResolver(), artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
}
use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class QueryCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
TestConsole console = new TestConsole();
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "query_command", tmp);
workspace.setUp();
ProjectFilesystem filesystem = new ProjectFilesystem(workspace.getDestPath().toRealPath().normalize());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
queryCommand = new QueryCommand();
queryCommand.outputAttributes = Suppliers.ofInstance(ImmutableSet.<String>of());
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, androidDirectoryResolver, artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class TargetsCommandTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
console = new TestConsole();
workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "target_command", tmp);
workspace.setUp();
filesystem = new ProjectFilesystem(workspace.getDestPath().toRealPath().normalize());
Cell cell = new TestCellBuilder().setFilesystem(filesystem).build();
AndroidDirectoryResolver androidDirectoryResolver = new FakeAndroidDirectoryResolver();
ArtifactCache artifactCache = new NoopArtifactCache();
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
objectMapper = ObjectMappers.newDefaultInstance();
targetsCommand = new TargetsCommand();
params = CommandRunnerParamsForTesting.createCommandRunnerParamsForTesting(console, cell, androidDirectoryResolver, artifactCache, eventBus, FakeBuckConfig.builder().build(), Platform.detect(), ImmutableMap.copyOf(System.getenv()), new FakeJavaPackageFinder(), objectMapper, Optional.empty());
executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
}
use of com.facebook.buck.artifact_cache.ArtifactCache in project buck by facebook.
the class ServedCacheIntegrationTest method testStoreAndFetchBorrowable.
@Test
public void testStoreAndFetchBorrowable() throws Exception {
webServer = new WebServer(/* port */
0, projectFilesystem, "/static/", MAPPER);
webServer.updateAndStartIfNeeded(ArtifactCaches.newServedCache(createMockLocalConfig("[cache]", "dir = test-cache", "serve_local_cache = true", "served_local_cache_mode = readwrite"), projectFilesystem));
ArtifactCache serverBackedCache = createArtifactCache(createMockLocalHttpCacheConfig(webServer.getPort().get()));
RuleKey ruleKey = new RuleKey("00111222333444");
ImmutableMap<String, String> metadata = ImmutableMap.of("some key", "some value");
Path originalDataPath = tmpDir.newFile();
String data = "you won't believe this!";
projectFilesystem.writeContentsToPath(data, originalDataPath);
LazyPath fetchedContents = LazyPath.ofInstance(tmpDir.newFile());
CacheResult cacheResult = serverBackedCache.fetch(ruleKey, fetchedContents);
assertThat(cacheResult.getType().isSuccess(), Matchers.is(false));
serverBackedCache.store(ArtifactInfo.builder().addRuleKeys(ruleKey).setMetadata(metadata).build(), BorrowablePath.borrowablePath(originalDataPath));
cacheResult = serverBackedCache.fetch(ruleKey, fetchedContents);
assertThat(cacheResult.getType().isSuccess(), Matchers.is(true));
assertThat(cacheResult.getMetadata(), Matchers.equalTo(metadata));
assertThat(projectFilesystem.readFileIfItExists(fetchedContents.get()).get(), Matchers.equalTo(data));
}
Aggregations