use of com.facebook.buck.event.WatchmanStatusEvent in project buck by facebook.
the class MachineReadableLogJsonViewTest method testWatchmanEvents.
@Test
public void testWatchmanEvents() throws Exception {
WatchmanStatusEvent createEvent = WatchmanStatusEvent.fileCreation("filename_new");
WatchmanStatusEvent deleteEvent = WatchmanStatusEvent.fileDeletion("filename_del");
WatchmanStatusEvent overflowEvent = WatchmanStatusEvent.overflow("reason");
// Configure the events so timestamps etc are there.
createEvent.configure(timestamp, nanoTime, threadUserNanoTime, threadId, buildId);
deleteEvent.configure(timestamp, nanoTime, threadUserNanoTime, threadId, buildId);
overflowEvent.configure(timestamp, nanoTime, threadUserNanoTime, threadId, buildId);
assertJsonEquals("{%s,\"filename\":\"filename_new\"}", WRITER.writeValueAsString(createEvent));
assertJsonEquals("{%s,\"filename\":\"filename_del\"}", WRITER.writeValueAsString(deleteEvent));
assertJsonEquals("{%s,\"reason\":\"reason\"}", WRITER.writeValueAsString(overflowEvent));
}
use of com.facebook.buck.event.WatchmanStatusEvent 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);
}
use of com.facebook.buck.event.WatchmanStatusEvent in project buck by facebook.
the class WatchmanWatcherTest method whenWatchmanReportsZeroFilesChangedThenPostEvent.
@Test
public void whenWatchmanReportsZeroFilesChangedThenPostEvent() throws IOException, InterruptedException {
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("files", ImmutableList.of());
WatchmanWatcher watcher = createWatcher(new EventBus("watchman test"), watchmanOutput);
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) {
zeroFilesChangedSeen |= event.getEventName().equals("WatchmanZeroFileChanges");
}
assertTrue(zeroFilesChangedSeen);
}
Aggregations