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"));
}
}
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"));
}
}
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"));
}
}
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();
}
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);
}
Aggregations