Search in sources :

Example 1 with NoopArtifactCache

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();
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) KnownBuildRuleTypesFactory(com.facebook.buck.rules.KnownBuildRuleTypesFactory) BroadcastEventListener(com.facebook.buck.event.listener.BroadcastEventListener) VersionedTargetGraphCache(com.facebook.buck.versions.VersionedTargetGraphCache) SingletonArtifactCacheFactory(com.facebook.buck.artifact_cache.SingletonArtifactCacheFactory) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) AndroidPlatformTarget(com.facebook.buck.android.AndroidPlatformTarget) ActionGraphCache(com.facebook.buck.rules.ActionGraphCache) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) ByteArrayInputStream(java.io.ByteArrayInputStream) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) DefaultClock(com.facebook.buck.timing.DefaultClock) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell)

Example 2 with NoopArtifactCache

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());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) ArtifactCache(com.facebook.buck.artifact_cache.ArtifactCache) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) Before(org.junit.Before)

Example 3 with NoopArtifactCache

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());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) ProjectWorkspace(com.facebook.buck.testutil.integration.ProjectWorkspace) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ArtifactCache(com.facebook.buck.artifact_cache.ArtifactCache) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) Before(org.junit.Before)

Example 4 with NoopArtifactCache

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());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) AndroidDirectoryResolver(com.facebook.buck.android.AndroidDirectoryResolver) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) ArtifactCache(com.facebook.buck.artifact_cache.ArtifactCache) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) Before(org.junit.Before)

Example 5 with NoopArtifactCache

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());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) Path(java.nio.file.Path) BorrowablePath(com.facebook.buck.io.BorrowablePath) Zip(com.facebook.buck.testutil.Zip) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeClock(com.facebook.buck.timing.FakeClock) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArtifactInfo(com.facebook.buck.artifact_cache.ArtifactInfo) BuildId(com.facebook.buck.model.BuildId) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) BorrowablePath(com.facebook.buck.io.BorrowablePath) ArtifactCache(com.facebook.buck.artifact_cache.ArtifactCache) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) Test(org.junit.Test)

Aggregations

NoopArtifactCache (com.facebook.buck.artifact_cache.NoopArtifactCache)6 FakeAndroidDirectoryResolver (com.facebook.buck.android.FakeAndroidDirectoryResolver)4 ArtifactCache (com.facebook.buck.artifact_cache.ArtifactCache)4 BuckEventBus (com.facebook.buck.event.BuckEventBus)4 FakeJavaPackageFinder (com.facebook.buck.jvm.java.FakeJavaPackageFinder)4 Cell (com.facebook.buck.rules.Cell)4 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)4 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)4 TestConsole (com.facebook.buck.testutil.TestConsole)4 Before (org.junit.Before)3 AndroidDirectoryResolver (com.facebook.buck.android.AndroidDirectoryResolver)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 BuildId (com.facebook.buck.model.BuildId)2 DefaultClock (com.facebook.buck.timing.DefaultClock)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Test (org.junit.Test)2 AndroidPlatformTarget (com.facebook.buck.android.AndroidPlatformTarget)1 ArtifactInfo (com.facebook.buck.artifact_cache.ArtifactInfo)1 SingletonArtifactCacheFactory (com.facebook.buck.artifact_cache.SingletonArtifactCacheFactory)1 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)1