use of com.facebook.buck.artifact_cache.NoopArtifactCache in project buck by facebook.
the class CleanCommandTest method createCommandRunnerParams.
private CommandRunnerParams createCommandRunnerParams() throws InterruptedException, IOException {
projectFilesystem = new FakeProjectFilesystem();
Cell cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
Supplier<AndroidPlatformTarget> androidPlatformTargetSupplier = AndroidPlatformTarget.EXPLODING_ANDROID_PLATFORM_TARGET_SUPPLIER;
return CommandRunnerParams.builder().setConsole(new TestConsole()).setStdIn(new ByteArrayInputStream("".getBytes("UTF-8"))).setCell(cell).setAndroidPlatformTargetSupplier(androidPlatformTargetSupplier).setArtifactCacheFactory(new SingletonArtifactCacheFactory(new NoopArtifactCache())).setBuckEventBus(BuckEventBusFactory.newInstance()).setParser(createMock(Parser.class)).setPlatform(Platform.detect()).setEnvironment(ImmutableMap.copyOf(System.getenv())).setJavaPackageFinder(new FakeJavaPackageFinder()).setObjectMapper(ObjectMappers.newDefaultInstance()).setClock(new DefaultClock()).setProcessManager(Optional.empty()).setWebServer(Optional.empty()).setBuckConfig(FakeBuckConfig.builder().build()).setFileHashCache(new StackedFileHashCache(ImmutableList.of())).setExecutors(ImmutableMap.of()).setBuildEnvironmentDescription(CommandRunnerParamsForTesting.BUILD_ENVIRONMENT_DESCRIPTION).setVersionedTargetGraphCache(new VersionedTargetGraphCache()).setActionGraphCache(new ActionGraphCache(new BroadcastEventListener())).setKnownBuildRuleTypesFactory(new KnownBuildRuleTypesFactory(new FakeProcessExecutor(), new FakeAndroidDirectoryResolver())).build();
}
use of com.facebook.buck.artifact_cache.NoopArtifactCache 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.NoopArtifactCache 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.NoopArtifactCache 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.NoopArtifactCache in project buck by facebook.
the class BuildInfoRecorderTest method testPerformUploadToArtifactCache.
@Test
public void testPerformUploadToArtifactCache() throws IOException, InterruptedException {
FakeProjectFilesystem filesystem = new FakeProjectFilesystem();
BuildInfoRecorder buildInfoRecorder = createBuildInfoRecorder(filesystem);
BuckEventBus bus = new BuckEventBus(new FakeClock(0), new BuildId("BUILD"));
final byte[] contents = "contents".getBytes();
Path file = Paths.get("file");
filesystem.writeBytesToPath(contents, file);
buildInfoRecorder.recordArtifact(file);
Path dir = Paths.get("dir");
filesystem.mkdirs(dir);
filesystem.writeBytesToPath(contents, dir.resolve("file"));
buildInfoRecorder.recordArtifact(dir);
// Record some metadata.
buildInfoRecorder.addMetadata("metadata", "metadata");
// Record some build metadata.
buildInfoRecorder.addBuildMetadata("build-metadata", "build-metadata");
buildInfoRecorder.writeMetadataToDisk(true);
final AtomicBoolean stored = new AtomicBoolean(false);
final ArtifactCache cache = new NoopArtifactCache() {
@Override
public boolean isStoreSupported() {
return true;
}
@Override
public ListenableFuture<Void> store(ArtifactInfo info, BorrowablePath output) {
stored.set(true);
// Verify the build metadata.
assertThat(info.getMetadata().get("build-metadata"), Matchers.equalTo("build-metadata"));
// Verify zip contents
try (Zip zip = new Zip(output.getPath(), /* forWriting */
false)) {
assertEquals(ImmutableSet.of("", "dir/", "buck-out/", "buck-out/bin/", "buck-out/bin/foo/", "buck-out/bin/foo/.bar/", "buck-out/bin/foo/.bar/metadata/"), zip.getDirNames());
assertEquals(ImmutableSet.of("dir/file", "file", "buck-out/bin/foo/.bar/metadata/metadata"), zip.getFileNames());
assertArrayEquals(contents, zip.readFully("file"));
assertArrayEquals(contents, zip.readFully("dir/file"));
} catch (IOException e) {
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
return Futures.immediateFuture(null);
}
};
buildInfoRecorder.performUploadToArtifactCache(ImmutableSet.of(new RuleKey("aa")), cache, bus);
assertTrue(stored.get());
}
Aggregations