use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method timestampsInLocaleWithDecimalCommaFormatCorrectly.
@Test
public void timestampsInLocaleWithDecimalCommaFormatCorrectly() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(new SuperConsoleConfig(FakeBuckConfig.builder().build()), new TestConsole(), fakeClock, silentSummaryVerbosity, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()), Optional.empty(), // Note we use de_DE to ensure we get a decimal comma in the output.
Locale.GERMAN, logPath, timeZone);
eventBus.register(listener);
eventBus.postWithoutConfiguring(configureTestEventAtTime(ProjectGenerationEvent.started(), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] GENERATING PROJECT...0,0s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new ProjectGenerationEvent.Finished(), 0L, TimeUnit.MILLISECONDS, 0L));
validateConsole(listener, 0L, ImmutableList.of("[-] GENERATING PROJECT...FINISHED 0,0s"));
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testBuildTimeDoesNotDisplayNegativeOffset.
@Test
public void testBuildTimeDoesNotDisplayNegativeOffset() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
BuildTarget fakeTarget = BuildTargetFactory.newInstance("//banana:stand");
ImmutableSet<BuildTarget> buildTargets = ImmutableSet.of(fakeTarget);
Iterable<String> buildArgs = Iterables.transform(buildTargets, Object::toString);
// Do a full parse and action graph cycle before the build event starts
// This sequencing occurs when running `buck project`
ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ActionGraphEvent.Started actionGraphStarted = ActionGraphEvent.started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(actionGraphStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 200L, ImmutableList.of("[+] PROCESSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(actionGraphStarted), 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String parsingLine = "[-] PROCESSING BUCK FILES...FINISHED 0.2s";
validateConsole(listener, 433L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.1s"));
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class StackedDownloaderTest method shouldIterativelyCheckEachDownloaderToSeeIfItWillReturnAnyFiles.
@Test
public void shouldIterativelyCheckEachDownloaderToSeeIfItWillReturnAnyFiles() throws URISyntaxException, IOException {
Downloader noMatch = EasyMock.createNiceMock("noMatch", Downloader.class);
Downloader exceptional = EasyMock.createNiceMock("exceptional", Downloader.class);
Downloader works = EasyMock.createNiceMock("works", Downloader.class);
Downloader neverCalled = EasyMock.createStrictMock("neverCalled", Downloader.class);
BuckEventBus eventBus = BuckEventBusFactory.newInstance();
URI uri = new URI("http://example.com/cheese/peas");
Path output = Paths.get("never used");
EasyMock.expect(noMatch.fetch(eventBus, uri, output)).andReturn(false);
EasyMock.expect(exceptional.fetch(eventBus, uri, output)).andThrow(new IOException(""));
EasyMock.expect(works.fetch(eventBus, uri, output)).andReturn(true);
// neverCalled is never called, and so needs no expectations.
EasyMock.replay(noMatch, exceptional, works, neverCalled);
StackedDownloader downloader = new StackedDownloader(ImmutableList.of(noMatch, exceptional, works, neverCalled));
boolean result = downloader.fetch(eventBus, uri, output);
assertTrue(result);
EasyMock.verify(noMatch, exceptional, works, neverCalled);
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class MissingSymbolsHandlerIntegrationTest method shouldFindNeededDependenciesFromSymbols.
@Test
public void shouldFindNeededDependenciesFromSymbols() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
MissingSymbolsHandler missingSymbolsHandler = MissingSymbolsHandler.create(projectFilesystem, allDescriptions, config, buckEventBus, new TestConsole(), DEFAULT_JAVAC_OPTIONS, environment);
MissingSymbolEvent missingSymbolEvent = MissingSymbolEvent.create(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), "com.example.a.A", MissingSymbolEvent.SymbolType.Java);
ImmutableSetMultimap<BuildTarget, BuildTarget> neededDeps = missingSymbolsHandler.getNeededDependencies(ImmutableList.of(missingSymbolEvent));
assertEquals("MissingSymbolsHandler failed to find the needed dependency.", neededDeps, ImmutableSetMultimap.of(BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/b:b"), BuildTargetFactory.newInstance(workspace.getDestPath(), "//java/com/example/a:a")));
}
use of com.facebook.buck.event.BuckEventBus in project buck by facebook.
the class JavaSymbolFinderIntegrationTest method shouldFindTargetDefiningSymbol.
@Test
public void shouldFindTargetDefiningSymbol() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "symbol_finder", temporaryFolder);
workspace.setUp();
ProjectFilesystem projectFilesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ImmutableMap<String, String> environment = ImmutableMap.copyOf(System.getenv());
Config rawConfig = Configs.createDefaultConfig(projectFilesystem.getRootPath());
BuckConfig config = new BuckConfig(rawConfig, projectFilesystem, Architecture.detect(), Platform.detect(), environment, new DefaultCellPathResolver(projectFilesystem.getRootPath(), rawConfig));
ParserConfig parserConfig = config.getView(ParserConfig.class);
PythonBuckConfig pythonBuckConfig = new PythonBuckConfig(config, new ExecutableFinder());
ImmutableSet<Description<?>> allDescriptions = KnownBuildRuleTypesTestUtil.getDefaultKnownBuildRuleTypes(projectFilesystem, environment).getAllDescriptions();
SrcRootsFinder srcRootsFinder = new SrcRootsFinder(projectFilesystem);
ProjectBuildFileParserFactory projectBuildFileParserFactory = new DefaultProjectBuildFileParserFactory(ProjectBuildFileParserOptions.builder().setProjectRoot(projectFilesystem.getRootPath()).setPythonInterpreter(pythonBuckConfig.getPythonInterpreter()).setAllowEmptyGlobs(parserConfig.getAllowEmptyGlobs()).setIgnorePaths(projectFilesystem.getIgnorePaths()).setBuildFileName(parserConfig.getBuildFileName()).setDefaultIncludes(parserConfig.getDefaultIncludes()).setDescriptions(allDescriptions).setBuildFileImportWhitelist(parserConfig.getBuildFileImportWhitelist()).build());
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance();
JavaSymbolFinder finder = new JavaSymbolFinder(projectFilesystem, srcRootsFinder, DEFAULT_JAVAC_OPTIONS, new ConstructorArgMarshaller(new DefaultTypeCoercerFactory(ObjectMappers.newDefaultInstance())), projectBuildFileParserFactory, config, buckEventBus, new TestConsole(), environment);
SetMultimap<String, BuildTarget> foundTargets = finder.findTargetsForSymbols(ImmutableSet.of("com.example.a.A"));
assertEquals("JavaSymbolFinder failed to find the right target.", ImmutableSetMultimap.of("com.example.a.A", BuildTargetFactory.newInstance(projectFilesystem, "//java/com/example/a:a")), foundTargets);
}
Aggregations