use of com.facebook.buck.io.WatchmanDiagnostic in project buck by facebook.
the class ProjectBuildFileParser method handleWatchmanDiagnostic.
private static void handleWatchmanDiagnostic(Path buildFile, String level, String message, BuckEventBus buckEventBus) throws IOException {
WatchmanDiagnostic.Level watchmanDiagnosticLevel;
switch(level) {
// then return.
case "debug":
LOG.debug("%s (watchman): %s", buildFile, message);
return;
case "info":
LOG.info("%s (watchman): %s", buildFile, message);
return;
case "warning":
watchmanDiagnosticLevel = WatchmanDiagnostic.Level.WARNING;
break;
case "error":
watchmanDiagnosticLevel = WatchmanDiagnostic.Level.ERROR;
break;
case "fatal":
throw new IOException(String.format("%s: %s", buildFile, message));
default:
throw new RuntimeException(String.format("Unrecognized watchman diagnostic level: %s (message=%s)", level, message));
}
WatchmanDiagnostic watchmanDiagnostic = WatchmanDiagnostic.of(watchmanDiagnosticLevel, message);
buckEventBus.post(new WatchmanDiagnosticEvent(watchmanDiagnostic));
}
use of com.facebook.buck.io.WatchmanDiagnostic in project buck by facebook.
the class WatchmanWatcherTest method whenWatchmanProducesAWarningThenWarningAddedToCache.
@Test
public void whenWatchmanProducesAWarningThenWarningAddedToCache() throws IOException, InterruptedException {
String message = "I'm a warning!";
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("files", ImmutableList.of(), "warning", message);
EventBus eventBus = new EventBus("watchman test");
WatchmanWatcher watcher = createWatcher(eventBus, watchmanOutput);
Set<WatchmanDiagnostic> diagnostics = new HashSet<>();
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance(new FakeClock(0));
buckEventBus.register(new WatchmanDiagnosticEventListener(buckEventBus, diagnostics));
watcher.postEvents(buckEventBus, WatchmanWatcher.FreshInstanceAction.NONE);
assertThat(diagnostics, hasItem(WatchmanDiagnostic.of(WatchmanDiagnostic.Level.WARNING, message)));
}
Aggregations