Search in sources :

Example 71 with Cell

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

the class BuildFileSpecTest method findWithWatchmanThrowsOnFailure.

@Test
public void findWithWatchmanThrowsOnFailure() 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());
    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"))), new IOException("Whoopsie!"));
    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();
    thrown.expect(IOException.class);
    thrown.expectMessage("Whoopsie!");
    recursiveSpec.findBuildFiles(cell, ParserConfig.BuildFileSearchMethod.WATCHMAN);
}
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) IOException(java.io.IOException) Cell(com.facebook.buck.rules.Cell) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) Test(org.junit.Test)

Example 72 with Cell

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

the class ParsePipelineTest method fetchGroup.

@Test
public void fetchGroup() throws Exception {
    try (Fixture fixture = createSynchronousExecutionFixture("groups")) {
        final Cell cell = fixture.getCell();
        TargetGroup group = fixture.getTargetGroupParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:group_one"));
        TargetNode<?, ?> node = fixture.getTargetNodeParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:foo"));
        assertThat(group.containsTarget(node.getBuildTarget()), is(true));
    }
}
Also used : TargetGroup(com.facebook.buck.rules.TargetGroup) Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 73 with Cell

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

the class ParsePipelineTest method badDependency.

@Test
public void badDependency() throws Exception {
    try (Fixture fixture = createMultiThreadedFixture("parse_rule_with_bad_dependency")) {
        Cell cell = fixture.getCell();
        fixture.getTargetNodeParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:base"));
    }
}
Also used : Cell(com.facebook.buck.rules.Cell) Test(org.junit.Test)

Example 74 with Cell

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

the class ParsePipelineTest method exceptionOnSwappedRawNodesInGetAllTargetNodes.

@Test
public void exceptionOnSwappedRawNodesInGetAllTargetNodes() throws Exception {
    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().getAllNodes(cell, aBuildFilePath);
    }
}
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 75 with Cell

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

the class ParsePipelineTest method speculativeDepsTraversal.

@Test
public void speculativeDepsTraversal() throws Exception {
    final Fixture fixture = createMultiThreadedFixture("pipeline_test");
    final Cell cell = fixture.getCell();
    TargetNode<?, ?> libTargetNode = fixture.getTargetNodeParsePipeline().getNode(cell, BuildTargetFactory.newInstance(cell.getFilesystem(), "//:lib"));
    waitForAll(libTargetNode.getDeps(), dep -> fixture.getTargetNodeParsePipelineCache().lookupComputedNode(cell, dep) != null);
    fixture.close();
}
Also used : Cell(com.facebook.buck.rules.Cell) 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