use of java.nio.file.PathMatcher in project copybara by google.
the class GlobTest method emptyIncludeExcludesEverything.
@Test
public void emptyIncludeExcludesEverything() throws Exception {
PathMatcher matcher = createPathMatcher("glob([], exclude = ['foo'])");
assertThat(matcher.matches(workdir.resolve("foo"))).isFalse();
assertThat(matcher.matches(workdir.resolve("bar/foo"))).isFalse();
assertThat(matcher.matches(workdir.resolve("baz"))).isFalse();
}
use of java.nio.file.PathMatcher in project copybara by google.
the class GlobTest method differenceOfDifferences.
@Test
public void differenceOfDifferences() throws Exception {
// a - (b - (c - d))
Glob glob = parseGlob("glob(['aaa/**']) - (glob(['**/bbb/**']) - (glob(['**/ccc/**']) - glob(['**/ddd'])))");
assertThat(glob.roots()).containsExactly("aaa");
PathMatcher matcher = glob.relativeTo(workdir);
assertThat(matcher.matches(workdir.resolve("aaa/xxx"))).isTrue();
assertThat(matcher.matches(workdir.resolve("aaa/bbb/xxx"))).isFalse();
assertThat(matcher.matches(workdir.resolve("aaa/bbb/ccc/xxx"))).isTrue();
assertThat(matcher.matches(workdir.resolve("aaa/bbb/ccc/ddd"))).isFalse();
assertThat(matcher.matches(workdir.resolve("xxx/bbb/ccc/xxx"))).isFalse();
}
use of java.nio.file.PathMatcher in project copybara by google.
the class GlobTest method differenceTest.
@Test
public void differenceTest() throws Exception {
Glob glob = parseGlob("glob(['foo/**']) - glob(['foo/bar/**'])");
assertThat(glob.roots()).containsExactly("foo");
PathMatcher matcher = glob.relativeTo(workdir);
assertThat(matcher.matches(workdir.resolve("foo/a"))).isTrue();
assertThat(matcher.matches(workdir.resolve("foo/bar/a"))).isFalse();
}
use of java.nio.file.PathMatcher in project copybara by google.
the class GlobTest method testSimpleInclude.
@Test
public void testSimpleInclude() throws IOException, ValidationException, RepoException {
PathMatcher pathMatcher = createPathMatcher("glob(['foo','bar'])");
assertThat(pathMatcher.matches(workdir.resolve("foo"))).isTrue();
assertThat(pathMatcher.matches(workdir.resolve("bar"))).isTrue();
assertThat(pathMatcher.matches(workdir.resolve("baz"))).isFalse();
}
use of java.nio.file.PathMatcher in project copybara by google.
the class GlobTest method iteratedDifference_doesNotCreateTallGlobTree.
@Test
public void iteratedDifference_doesNotCreateTallGlobTree() throws Exception {
String config = "glob(['foo/**'])";
for (int i = 0; i < 1000; i++) {
config += String.format(" - glob(['foo/file%d'])", i);
}
Glob glob = parseGlob(config);
assertThat(glob.roots()).containsExactly("foo");
assertThat(glob.heightOfGlobTree()).isLessThan(3);
PathMatcher matcher = glob.relativeTo(workdir);
assertThat(matcher.matches(workdir.resolve("foo/file777"))).isFalse();
assertThat(matcher.matches(workdir.resolve("foo/file1000"))).isTrue();
}
Aggregations