use of com.facebook.buck.io.PathOrGlobMatcher in project buck by facebook.
the class ProjectTest method testDoNotIgnoreAllOfBuckOut.
@Test
public void testDoNotIgnoreAllOfBuckOut() {
SourcePathResolver resolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
ProjectFilesystem projectFilesystem = FakeProjectFilesystem.createJavaOnlyFilesystem("/opt/src/buck");
BuildTarget buildTarget = BuildTarget.builder(projectFilesystem.getRootPath(), "//", "base").build();
BuildRule buildRule = new FakeBuildRule(buildTarget, resolver);
SerializableModule module = new SerializableModule(buildRule, buildTarget);
Project.addRootExcludes(module, buildRule, projectFilesystem);
ImmutableSortedSet.Builder<SourceFolder> expectedExcludeFolders = ImmutableSortedSet.orderedBy(SerializableModule.ALPHABETIZER);
expectedExcludeFolders.add(new SourceFolder("file://$MODULE_DIR$/buck-out/bin", /* isTestSource */
false));
expectedExcludeFolders.add(new SourceFolder("file://$MODULE_DIR$/buck-out/log", /* isTestSource */
false));
expectedExcludeFolders.add(new SourceFolder("file://$MODULE_DIR$/buck-out/tmp", /* isTestSource */
false));
for (Path ignorePath : FluentIterable.from(projectFilesystem.getIgnorePaths()).filter(input -> input.getType() == PathOrGlobMatcher.Type.PATH).transform(PathOrGlobMatcher::getPath)) {
if (!ignorePath.equals(projectFilesystem.getBuckPaths().getBuckOut()) && !ignorePath.equals(projectFilesystem.getBuckPaths().getGenDir())) {
expectedExcludeFolders.add(new SourceFolder("file://$MODULE_DIR$/" + MorePaths.pathWithUnixSeparators(ignorePath), /* isTestSource */
false));
}
}
assertEquals("Specific subfolders of buck-out should be excluded rather than all of buck-out.", expectedExcludeFolders.build(), module.excludeFolders);
}
use of com.facebook.buck.io.PathOrGlobMatcher in project buck by facebook.
the class WatchmanWatcherIntegrationTest method globMatchesWholeName.
@Test
public void globMatchesWholeName() throws IOException, InterruptedException {
WatchmanWatcher watcher = createWatchmanWatcher(new PathOrGlobMatcher("*.txt"));
// Create a dot-file which should be ignored by the above glob.
Path path = tmp.getRoot().getFileSystem().getPath("foo/bar/hello.txt");
Files.createDirectories(tmp.getRoot().resolve(path).getParent());
Files.write(tmp.getRoot().resolve(path), new byte[0]);
// Verify we still get an event for the created path.
watcher.postEvents(new BuckEventBus(new FakeClock(0), new BuildId()), WatchmanWatcher.FreshInstanceAction.NONE);
ImmutableList<WatchEvent<?>> events = watchmanEventCollector.getEvents();
assertThat(events.size(), Matchers.equalTo(1));
WatchEvent<?> event = events.get(0);
Path eventPath = (Path) event.context();
assertThat(eventPath, Matchers.equalTo(path));
assertSame(event.kind(), StandardWatchEventKinds.ENTRY_CREATE);
}
use of com.facebook.buck.io.PathOrGlobMatcher in project buck by facebook.
the class WatchmanWatcherIntegrationTest method ignoreDotFileInGlob.
@Test
public void ignoreDotFileInGlob() throws IOException, InterruptedException {
WatchmanWatcher watcher = createWatchmanWatcher(new PathOrGlobMatcher("**/*.swp"));
// Create a dot-file which should be ignored by the above glob.
Path path = tmp.getRoot().getFileSystem().getPath("foo/bar/.hello.swp");
Files.createDirectories(tmp.getRoot().resolve(path).getParent());
Files.write(tmp.getRoot().resolve(path), new byte[0]);
// Verify we don't get an event for the path.
watcher.postEvents(new BuckEventBus(new FakeClock(0), new BuildId()), WatchmanWatcher.FreshInstanceAction.NONE);
assertThat(watchmanEventCollector.getEvents(), Matchers.empty());
}
use of com.facebook.buck.io.PathOrGlobMatcher 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.PathOrGlobMatcher 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);
}
Aggregations