Search in sources :

Example 36 with Cell

use of com.facebook.buck.rules.Cell in project buck by facebook.

the class ParsePipelineTest method exceptionOnFetchingGroupAsNode.

@Test
public void exceptionOnFetchingGroupAsNode() throws Exception {
    try (Fixture fixture = createSynchronousExecutionFixture("groups")) {
        final Cell cell = fixture.getCell();
        expectedException.expect(NoSuchBuildTargetException.class);
        fixture.getTargetGroupParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:foo"));
    }
}
Also used : Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 37 with Cell

use of com.facebook.buck.rules.Cell in project buck by facebook.

the class ParsePipelineTest method exceptionOnSwappedRawNodesInGetTargetNode.

@Test
public void exceptionOnSwappedRawNodesInGetTargetNode() throws Exception {
    // should be and we want to test both of them.
    try (Fixture fixture = createSynchronousExecutionFixture("pipeline_test")) {
        Cell cell = fixture.getCell();
        Path rootBuildFilePath = cell.getFilesystem().resolve("BUCK");
        Path aBuildFilePath = cell.getFilesystem().resolve("a/BUCK");
        fixture.getTargetNodeParsePipeline().getAllNodes(cell, rootBuildFilePath);
        Optional<ImmutableSet<Map<String, Object>>> rootRawNodes = fixture.getRawNodeParsePipelineCache().lookupComputedNode(cell, rootBuildFilePath);
        fixture.getRawNodeParsePipelineCache().putComputedNodeIfNotPresent(cell, aBuildFilePath, rootRawNodes.get());
        expectedException.expect(IllegalStateException.class);
        expectedException.expectMessage("Raw data claims to come from [], but we tried rooting it at [a].");
        fixture.getTargetNodeParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//a:lib"));
    }
}
Also used : Path(java.nio.file.Path) ImmutableSet(com.google.common.collect.ImmutableSet) Matchers.containsString(org.hamcrest.Matchers.containsString) Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 38 with Cell

use of com.facebook.buck.rules.Cell in project buck by facebook.

the class ParsePipelineTest method missingTarget.

@Test
public void missingTarget() throws Exception {
    try (Fixture fixture = createMultiThreadedFixture("parse_rule_with_bad_dependency")) {
        Cell cell = fixture.getCell();
        expectedException.expect(NoSuchBuildTargetException.class);
        expectedException.expectMessage("No rule found when resolving target //:notthere");
        fixture.getTargetNodeParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:notthere"));
    }
}
Also used : Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 39 with Cell

use of com.facebook.buck.rules.Cell in project buck by facebook.

the class ParsePipelineTest method speculativeDepsTraversalWhenGettingAllNodes.

@Test
public void speculativeDepsTraversalWhenGettingAllNodes() throws Exception {
    final Fixture fixture = createMultiThreadedFixture("pipeline_test");
    final Cell cell = fixture.getCell();
    ImmutableSet<TargetNode<?, ?>> libTargetNodes = fixture.getTargetNodeParsePipeline().getAllNodes(cell, fixture.getCell().getFilesystem().resolve("BUCK"));
    FluentIterable<BuildTarget> allDeps = FluentIterable.from(libTargetNodes).transformAndConcat(new Function<TargetNode<?, ?>, Iterable<BuildTarget>>() {

        @Override
        public Iterable<BuildTarget> apply(TargetNode<?, ?> input) {
            return input.getDeps();
        }
    });
    waitForAll(allDeps, dep -> fixture.getTargetNodeParsePipelineCache().lookupComputedNode(cell, dep) != null);
    fixture.close();
}
Also used : TargetNode(com.facebook.buck.rules.TargetNode) FluentIterable(com.google.common.collect.FluentIterable) BuildTarget(com.facebook.buck.model.BuildTarget) Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 40 with Cell

use of com.facebook.buck.rules.Cell in project buck by facebook.

the class BuildFileSpecTest method findWithWatchmanSucceeds.

@Test
public void findWithWatchmanSucceeds() throws IOException, InterruptedException {
    Path watchRoot = Paths.get(".").toAbsolutePath().normalize();
    FakeProjectFilesystem filesystem = new FakeProjectFilesystem(watchRoot.resolve("project-name"));
    Path buildFile = Paths.get("a", "BUCK");
    BuildFileSpec recursiveSpec = BuildFileSpec.fromRecursivePath(buildFile.getParent(), filesystem.getRootPath());
    ImmutableSet<Path> expectedBuildFiles = ImmutableSet.of(filesystem.resolve(buildFile));
    FakeWatchmanClient fakeWatchmanClient = new FakeWatchmanClient(0, ImmutableMap.of(ImmutableList.of("query", watchRoot.toString(), ImmutableMap.of("relative_root", "project-name", "sync_timeout", 0, "path", ImmutableList.of("a"), "fields", ImmutableList.of("name"), "expression", ImmutableList.of("allof", "exists", ImmutableList.of("name", "BUCK"), ImmutableList.of("type", "f")))), ImmutableMap.of("files", ImmutableList.of("a/BUCK"))));
    Cell cell = new TestCellBuilder().setFilesystem(filesystem).setWatchman(new Watchman(ImmutableMap.of(filesystem.getRootPath(), ProjectWatch.of(watchRoot.toString(), Optional.of("project-name"))), ImmutableSet.of(Watchman.Capability.SUPPORTS_PROJECT_WATCH, Watchman.Capability.DIRNAME, Watchman.Capability.WILDMATCH_GLOB), ImmutableMap.of(), Optional.of(Paths.get(".watchman-sock")), Optional.of(fakeWatchmanClient))).build();
    ImmutableSet<Path> actualBuildFiles = recursiveSpec.findBuildFiles(cell, ParserConfig.BuildFileSearchMethod.WATCHMAN);
    assertEquals(expectedBuildFiles, actualBuildFiles);
}
Also used : Path(java.nio.file.Path) Watchman(com.facebook.buck.io.Watchman) FakeWatchmanClient(com.facebook.buck.io.FakeWatchmanClient) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) Cell(com.facebook.buck.rules.Cell) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Test(org.junit.Test)

Aggregations

Cell (com.facebook.buck.rules.Cell)87 Test (org.junit.Test)57 Path (java.nio.file.Path)46 TestCellBuilder (com.facebook.buck.rules.TestCellBuilder)41 BuildTarget (com.facebook.buck.model.BuildTarget)25 BuckConfig (com.facebook.buck.cli.BuckConfig)24 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)22 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)21 PathSourcePath (com.facebook.buck.rules.PathSourcePath)15 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)14 ImmutableSet (com.google.common.collect.ImmutableSet)14 BuckEventBus (com.facebook.buck.event.BuckEventBus)12 ImmutableMap (com.google.common.collect.ImmutableMap)12 BroadcastEventListener (com.facebook.buck.event.listener.BroadcastEventListener)11 ParserConfig (com.facebook.buck.parser.ParserConfig)11 IOException (java.io.IOException)11 Map (java.util.Map)11 TargetNode (com.facebook.buck.rules.TargetNode)10 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)10 ImmutableList (com.google.common.collect.ImmutableList)10