use of com.facebook.buck.io.WatchmanQuery in project buck by facebook.
the class WatchmanWatcherTest method watchmanQueryWithExcludePathsAddsMatchExpressionToQueryIfDirnameNotAvailable.
@Test
public void watchmanQueryWithExcludePathsAddsMatchExpressionToQueryIfDirnameNotAvailable() {
WatchmanQuery query = WatchmanWatcher.createQuery(ProjectWatch.of("/path/to/repo", Optional.empty()), ImmutableSet.of(new PathOrGlobMatcher(Paths.get("foo")), new PathOrGlobMatcher(Paths.get("bar/baz"))), ImmutableSet.of());
assertEquals(WatchmanQuery.of("/path/to/repo", ImmutableMap.of("expression", ImmutableList.of("not", ImmutableList.of("anyof", ImmutableList.of("type", "d"), ImmutableList.of("match", "foo" + File.separator + "*", "wholename"), ImmutableList.of("match", "bar" + File.separator + "baz" + File.separator + "*", "wholename"))), "empty_on_fresh_instance", true, "fields", ImmutableList.of("name", "exists", "new"))), query);
}
use of com.facebook.buck.io.WatchmanQuery in project buck by facebook.
the class WatchmanWatcherTest method watchmanQueryRelativizesExcludePaths.
@Test
public void watchmanQueryRelativizesExcludePaths() {
String watchRoot = Paths.get("/path/to/repo").toAbsolutePath().toString();
WatchmanQuery query = WatchmanWatcher.createQuery(ProjectWatch.of(watchRoot, Optional.empty()), ImmutableSet.of(new PathOrGlobMatcher(Paths.get("/path/to/repo/foo").toAbsolutePath()), new PathOrGlobMatcher(Paths.get("/path/to/repo/bar/baz").toAbsolutePath())), ImmutableSet.of(Watchman.Capability.DIRNAME));
assertEquals(WatchmanQuery.of(watchRoot, ImmutableMap.of("expression", ImmutableList.of("not", ImmutableList.of("anyof", ImmutableList.of("type", "d"), ImmutableList.of("dirname", "foo"), ImmutableList.of("dirname", MorePaths.pathWithPlatformSeparators("bar/baz")))), "empty_on_fresh_instance", true, "fields", ImmutableList.of("name", "exists", "new"))), query);
}
use of com.facebook.buck.io.WatchmanQuery in project buck by facebook.
the class WatchmanWatcherTest method watchmanQueryWithExcludeGlobsAddsExpressionToQuery.
@Test
public void watchmanQueryWithExcludeGlobsAddsExpressionToQuery() {
WatchmanQuery query = WatchmanWatcher.createQuery(ProjectWatch.of("/path/to/repo", Optional.empty()), ImmutableSet.of(new PathOrGlobMatcher("*.pbxproj")), ImmutableSet.of(Watchman.Capability.DIRNAME));
assertEquals(WatchmanQuery.of("/path/to/repo", ImmutableMap.of("expression", ImmutableList.of("not", ImmutableList.of("anyof", ImmutableList.of("type", "d"), ImmutableList.of("match", "*.pbxproj", "wholename", ImmutableMap.<String, Object>of("includedotfiles", true)))), "empty_on_fresh_instance", true, "fields", ImmutableList.of("name", "exists", "new"))), query);
}
use of com.facebook.buck.io.WatchmanQuery in project buck by facebook.
the class WatchmanWatcher method postEvents.
/**
* Query Watchman for file change events. If too many events are pending or an error occurs
* an overflow event is posted to the EventBus signalling that events may have been lost
* (and so typically caches must be cleared to avoid inconsistency). Interruptions and
* IOExceptions are propagated to callers, but typically if overflow events are handled
* conservatively by subscribers then no other remedial action is required.
*
* Any diagnostics posted by Watchman are added to watchmanDiagnosticCache.
*/
public void postEvents(BuckEventBus buckEventBus, FreshInstanceAction freshInstanceAction) throws IOException, InterruptedException {
// Speculatively set to false
AtomicBoolean filesHaveChanged = new AtomicBoolean(false);
for (Path cellPath : queries.keySet()) {
WatchmanQuery query = queries.get(cellPath);
WatchmanCursor cursor = cursors.get(cellPath);
if (query != null && cursor != null) {
postEvents(buckEventBus, freshInstanceAction, query, cursor, filesHaveChanged);
}
}
if (!filesHaveChanged.get()) {
buckEventBus.post(WatchmanStatusEvent.zeroFileChanges());
}
}
use of com.facebook.buck.io.WatchmanQuery in project buck by facebook.
the class WatchmanWatcherTest method watchmanQueryWithExcludePathsAddsExpressionToQuery.
@Test
public void watchmanQueryWithExcludePathsAddsExpressionToQuery() {
WatchmanQuery query = WatchmanWatcher.createQuery(ProjectWatch.of("/path/to/repo", Optional.empty()), ImmutableSet.of(new PathOrGlobMatcher(Paths.get("foo")), new PathOrGlobMatcher(Paths.get("bar/baz"))), ImmutableSet.of(Watchman.Capability.DIRNAME));
assertEquals(WatchmanQuery.of("/path/to/repo", ImmutableMap.of("expression", ImmutableList.of("not", ImmutableList.of("anyof", ImmutableList.of("type", "d"), ImmutableList.of("dirname", "foo"), ImmutableList.of("dirname", MorePaths.pathWithPlatformSeparators("bar/baz")))), "empty_on_fresh_instance", true, "fields", ImmutableList.of("name", "exists", "new"))), query);
}
Aggregations