use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class BuckEventOrdererTest method testMergesSingleEventAtStartCorrectly.
@Test
public void testMergesSingleEventAtStartCorrectly() {
BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent second = createUniqueEvent(1, TimeUnit.MILLISECONDS, THREAD_TWO);
BuckEvent third = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
orderer.add(second);
orderer.add(first);
orderer.add(third);
}
assertThat(serializedEvents, Matchers.contains(first, second, third));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class BuckEventOrdererTest method testMergesTwoInterleavedEventSeries.
@Test
public void testMergesTwoInterleavedEventSeries() {
BuckEvent first = createUniqueEvent(0, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent second = createUniqueEvent(1, TimeUnit.MILLISECONDS, THREAD_TWO);
BuckEvent third = createUniqueEvent(2, TimeUnit.MILLISECONDS, THREAD_ONE);
BuckEvent fourth = createUniqueEvent(3, TimeUnit.MILLISECONDS, THREAD_TWO);
try (BuckEventOrderer<BuckEvent> orderer = new BuckEventOrderer<>(addToSerializedEventsFunction, MAX_SKEW, TimeUnit.MILLISECONDS)) {
orderer.add(second);
orderer.add(first);
orderer.add(fourth);
orderer.add(third);
}
assertThat(serializedEvents, Matchers.contains(first, second, third, fourth));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class UnskippedRulesTrackerTest method assertReceivedEvent.
private void assertReceivedEvent(int numRules) throws InterruptedException {
BuckEvent event = events.take();
assertThat(event, is(instanceOf(BuildEvent.UnskippedRuleCountUpdated.class)));
BuildEvent.UnskippedRuleCountUpdated countEvent = (BuildEvent.UnskippedRuleCountUpdated) event;
assertThat(countEvent.getNumRules(), is(equalTo(numRules)));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class WorkerShellStepTest method testStdErrIsPrintedAsErrorIfJobFails.
@Test
public void testStdErrIsPrintedAsErrorIfJobFails() throws IOException, InterruptedException {
String stderr = "my stderr";
ExecutionContext context = createExecutionContextWith(1, "", stderr);
WorkerShellStep step = createWorkerShellStep(createJobParams(ImmutableList.of(startupCommand), startupArgs, ImmutableMap.of(), "myJobArgs"), null, null);
FakeBuckEventListener listener = new FakeBuckEventListener();
context.getBuckEventBus().register(listener);
int exitCode = step.execute(context).getExitCode();
assertThat(exitCode, Matchers.equalTo(1));
// assert that the job's stderr was written to the console as error, not as warning
BuckEvent firstEvent = listener.getEvents().get(0);
assertTrue(firstEvent instanceof ConsoleEvent);
assertThat(((ConsoleEvent) firstEvent).getLevel(), Matchers.is(Level.SEVERE));
assertThat(((ConsoleEvent) firstEvent).getMessage(), Matchers.is(stderr));
}
use of com.facebook.buck.event.BuckEvent in project buck by facebook.
the class WatchmanWatcherTest method whenWatchmanCellReportsFilesChangedThenPostEvent.
@Test
public void whenWatchmanCellReportsFilesChangedThenPostEvent() throws IOException, InterruptedException {
ImmutableMap<String, Object> watchmanRootOutput = ImmutableMap.of("files", ImmutableList.of());
ImmutableMap<String, Object> watchmanSecondaryOutput = ImmutableMap.of("files", ImmutableList.of(ImmutableMap.<String, Object>of("name", "foo/bar/baz")));
WatchmanWatcher watcher = new WatchmanWatcher(new EventBus("watchman test"), new FakeWatchmanClient(0, ImmutableMap.of(FAKE_CLOCK_QUERY, watchmanRootOutput, FAKE_SECONDARY_QUERY.toList("c:0:0"), watchmanSecondaryOutput)), 10000, ImmutableMap.of(FAKE_ROOT, FAKE_QUERY, FAKE_SECONDARY_ROOT, FAKE_SECONDARY_QUERY), ImmutableMap.of(FAKE_ROOT, new WatchmanCursor("c:0:0"), FAKE_SECONDARY_ROOT, new WatchmanCursor("c:0:0")));
final Set<BuckEvent> events = Sets.newHashSet();
BuckEventBus bus = BuckEventBusFactory.newInstance(new FakeClock(0));
bus.register(new Object() {
@Subscribe
public void listen(WatchmanStatusEvent event) {
events.add(event);
}
});
watcher.postEvents(bus, WatchmanWatcher.FreshInstanceAction.POST_OVERFLOW_EVENT);
boolean zeroFilesChangedSeen = false;
System.err.println(String.format("Events: %d", events.size()));
for (BuckEvent event : events) {
System.err.println(String.format("Event: %s", event));
zeroFilesChangedSeen |= event.getEventName().equals("WatchmanZeroFileChanges");
}
assertFalse(zeroFilesChangedSeen);
}
Aggregations