use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class BuildTracesTest method testTraceAttributesThrowsWhenEmpty.
@Test(expected = HumanReadableException.class)
public void testTraceAttributesThrowsWhenEmpty() throws IOException {
FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem(new FakeClock(TimeUnit.MILLISECONDS.toNanos(2000L)));
projectFilesystem.mkdirs(projectFilesystem.getBuckPaths().getTraceDir());
BuildTraces helper = new BuildTraces(projectFilesystem);
helper.getTraceAttributesFor("nonexistent");
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class WatchmanWatcherTest method whenNewIsTrueThenCreateEventIsGenerated.
@Test
public void whenNewIsTrueThenCreateEventIsGenerated() throws IOException, InterruptedException {
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("files", ImmutableList.of(ImmutableMap.<String, Object>of("name", "foo/bar/baz", "new", true)));
Capture<WatchEvent<Path>> eventCapture = newCapture();
EventBus eventBus = createStrictMock(EventBus.class);
eventBus.post(capture(eventCapture));
replay(eventBus);
WatchmanWatcher watcher = createWatcher(eventBus, watchmanOutput);
watcher.postEvents(BuckEventBusFactory.newInstance(new FakeClock(0)), WatchmanWatcher.FreshInstanceAction.NONE);
verify(eventBus);
assertEquals("Should be create event.", StandardWatchEventKinds.ENTRY_CREATE, eventCapture.getValue().kind());
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class WatchmanWatcherTest method whenNewAndNotExistsThenDeleteEventIsGenerated.
@Test
public void whenNewAndNotExistsThenDeleteEventIsGenerated() throws IOException, InterruptedException {
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("files", ImmutableList.of(ImmutableMap.<String, Object>of("name", "foo/bar/baz", "new", true, "exists", false)));
Capture<WatchEvent<Path>> eventCapture = newCapture();
EventBus eventBus = createStrictMock(EventBus.class);
eventBus.post(capture(eventCapture));
replay(eventBus);
WatchmanWatcher watcher = createWatcher(eventBus, watchmanOutput);
watcher.postEvents(BuckEventBusFactory.newInstance(new FakeClock(0)), WatchmanWatcher.FreshInstanceAction.NONE);
verify(eventBus);
assertEquals("Should be delete event.", StandardWatchEventKinds.ENTRY_DELETE, eventCapture.getValue().kind());
}
use of com.facebook.buck.timing.FakeClock 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);
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class WatchmanWatcherTest method whenParseTimesOutThenOverflowGenerated.
@Test
public void whenParseTimesOutThenOverflowGenerated() throws IOException, InterruptedException {
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("version", "2.9.2", "clock", "c:1386170113:26390:5:50273", "is_fresh_instance", true, "files", ImmutableList.of());
final Set<WatchEvent<?>> events = Sets.newHashSet();
EventBus bus = new EventBus("watchman test");
bus.register(new Object() {
@Subscribe
public void listen(WatchEvent<?> event) {
events.add(event);
}
});
WatchmanWatcher watcher = createWatcher(bus, new FakeWatchmanClient(10000000000L, /* queryElapsedTimeNanos */
ImmutableMap.of(FAKE_UUID_QUERY, watchmanOutput)), -1);
watcher.postEvents(BuckEventBusFactory.newInstance(new FakeClock(0)), WatchmanWatcher.FreshInstanceAction.NONE);
boolean overflowSeen = false;
for (WatchEvent<?> event : events) {
overflowSeen |= event.kind().equals(StandardWatchEventKinds.OVERFLOW);
}
assertTrue(overflowSeen);
}
Aggregations