use of com.facebook.buck.event.listener.BroadcastEventListener 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.event.listener.BroadcastEventListener in project buck by facebook.
the class InterCellIntegrationTest method parseTargetForXCellVisibility.
private void parseTargetForXCellVisibility(String targetName) throws IOException, InterruptedException, BuildFileParseException, BuildTargetException {
Pair<ProjectWorkspace, ProjectWorkspace> cells = prepare("inter-cell/visibility/primary", "inter-cell/visibility/secondary");
ProjectWorkspace primary = cells.getFirst();
ProjectWorkspace secondary = cells.getSecond();
registerCell(primary, "primary", primary);
registerCell(secondary, "primary", primary);
// We could just do a build, but that's a little extreme since all we need is the target graph
TypeCoercerFactory coercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
Parser parser = new Parser(new BroadcastEventListener(), primary.asCell().getBuckConfig().getView(ParserConfig.class), coercerFactory, new ConstructorArgMarshaller(coercerFactory));
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
Cell primaryCell = primary.asCell();
BuildTarget namedTarget = BuildTargetFactory.newInstance(primaryCell.getFilesystem(), targetName);
// It's enough that this parses cleanly.
parser.buildTargetGraph(eventBus, primaryCell, false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(namedTarget));
}
use of com.facebook.buck.event.listener.BroadcastEventListener in project buck by facebook.
the class IntraCellIntegrationTest method shouldTreatCellBoundariesAsVisibilityBoundariesToo.
@SuppressWarnings("PMD.EmptyCatchBlock")
@Test
public void shouldTreatCellBoundariesAsVisibilityBoundariesToo() throws IOException, InterruptedException, BuildFileParseException, BuildTargetException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "intracell/visibility", tmp);
workspace.setUp();
// We don't need to do a build. It's enough to just parse these things.
Cell cell = workspace.asCell();
TypeCoercerFactory coercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
Parser parser = new Parser(new BroadcastEventListener(), cell.getBuckConfig().getView(ParserConfig.class), coercerFactory, new ConstructorArgMarshaller(coercerFactory));
// This parses cleanly
parser.buildTargetGraph(BuckEventBusFactory.newInstance(), cell, false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(cell.getFilesystem(), "//just-a-directory:rule")));
Cell childCell = cell.getCell(BuildTargetFactory.newInstance(workspace.getDestPath().resolve("child-repo"), "//:child-target"));
try {
// Whereas, because visibility is limited to the same cell, this won't.
parser.buildTargetGraph(BuckEventBusFactory.newInstance(), childCell, false, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()), ImmutableSet.of(BuildTargetFactory.newInstance(childCell.getFilesystem(), "//:child-target")));
fail("Didn't expect parsing to work because of visibility");
} catch (HumanReadableException e) {
// This is expected
}
}
use of com.facebook.buck.event.listener.BroadcastEventListener in project buck by facebook.
the class DistBuildFileHashesIntegrationTest method createDistBuildFileHashes.
private DistBuildFileHashes createDistBuildFileHashes(TargetGraph targetGraph, Cell rootCell) throws IOException {
ActionGraphCache cache = new ActionGraphCache(new BroadcastEventListener());
ActionGraphAndResolver actionGraphAndResolver = cache.getActionGraph(BuckEventBusFactory.newInstance(), true, false, targetGraph, KEY_SEED);
BuildRuleResolver ruleResolver = actionGraphAndResolver.getResolver();
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(ruleResolver);
SourcePathResolver sourcePathResolver = new SourcePathResolver(ruleFinder);
DistBuildCellIndexer cellIndexer = new DistBuildCellIndexer(rootCell);
ImmutableList.Builder<ProjectFileHashCache> allCaches = ImmutableList.builder();
allCaches.add(DefaultFileHashCache.createDefaultFileHashCache(rootCell.getFilesystem()));
for (Path cellPath : rootCell.getKnownRoots()) {
Cell cell = rootCell.getCell(cellPath);
allCaches.add(DefaultFileHashCache.createDefaultFileHashCache(cell.getFilesystem()));
}
allCaches.addAll(DefaultFileHashCache.createOsRootDirectoriesCaches());
StackedFileHashCache stackedCache = new StackedFileHashCache(allCaches.build());
return new DistBuildFileHashes(actionGraphAndResolver.getActionGraph(), sourcePathResolver, ruleFinder, stackedCache, cellIndexer, MoreExecutors.newDirectExecutorService(), /* keySeed */
KEY_SEED, rootCell);
}
use of com.facebook.buck.event.listener.BroadcastEventListener in project buck by facebook.
the class ParserTest method targetWithSourceFileChangesHash.
@Test
public void targetWithSourceFileChangesHash() throws Exception {
tempDir.newFolder("foo");
Path testFooBuckFile = tempDir.newFile("foo/BUCK");
Files.write(testFooBuckFile, "java_library(name = 'lib', srcs=glob(['*.java']), visibility=['PUBLIC'])\n".getBytes(UTF_8));
BuildTarget fooLibTarget = BuildTarget.builder(cellRoot, "//foo", "lib").build();
HashCode original = buildTargetGraphAndGetHashCodes(parser, fooLibTarget).get(fooLibTarget);
DefaultTypeCoercerFactory typeCoercerFactory = new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance());
parser = new Parser(new BroadcastEventListener(), cell.getBuckConfig().getView(ParserConfig.class), typeCoercerFactory, new ConstructorArgMarshaller(typeCoercerFactory));
Path testFooJavaFile = tempDir.newFile("foo/Foo.java");
Files.write(testFooJavaFile, "// Ceci n'est pas une Javafile\n".getBytes(UTF_8));
HashCode updated = buildTargetGraphAndGetHashCodes(parser, fooLibTarget).get(fooLibTarget);
assertNotEquals(original, updated);
}
Aggregations