diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java b/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java index 62f5ca1f0c..11d301f4f8 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/GlobCacheTest.java @@ -237,6 +237,61 @@ public class GlobCacheTest { "foo/second.js", "bar/second.js"); } + @Test + public void testSingleFileExclude_Star() throws Exception { + assertThat(cache.glob(list("*"), list("first.txt"), false)).containsExactly( + "BUILD", "bar", "first.js", "foo", "second.js", "second.txt").inOrder(); + } + + @Test + public void testSingleFileExclude_StarStar() throws Exception { + assertThat(cache.glob(list("**"), list("first.txt"), false)).containsExactly( + "BUILD", "bar", "bar/first.js", "bar/second.js", "first.js", "foo", "foo/first.js", + "foo/second.js", "second.js", "second.txt").inOrder(); + } + + @Test + public void testExcludeAll_Star() throws Exception { + assertThat(cache.glob(list("*"), list("*"), false)).isEmpty(); + } + + @Test + public void testExcludeAll_Star_NoMatchesAnyway() throws Exception { + assertThat(cache.glob(list("nope"), list("*"), false)).isEmpty(); + } + + @Test + public void testExcludeAll_StarStar() throws Exception { + assertThat(cache.glob(list("**"), list("**"), false)).isEmpty(); + } + + @Test + public void testExcludeAll_Manual() throws Exception { + assertThat(cache.glob(list("**"), list("*", "*/*", "*/*/*"), false)).isEmpty(); + } + + @Test + public void testSingleFileExcludeDoesntMatch() throws Exception { + assertThat(cache.glob(list("first.txt"), list("nope.txt"), false)).containsExactly("first.txt"); + } + + @Test + public void testExcludeDirectory() throws Exception { + assertThat(cache.glob(list("foo/*"), NONE, true)).containsExactly( + "foo/first.js", "foo/second.js"); + assertThat(cache.glob(list("foo/*"), list("foo"), false)).containsExactly( + "foo/first.js", "foo/second.js"); + } + + @Test + public void testChildGlobWithChildExclude() throws Exception { + assertThat(cache.glob(list("foo/*"), list("foo/*"), false)).isEmpty(); + assertThat(cache.glob(list("foo/first.js", "foo/second.js"), list("foo/*"), false)).isEmpty(); + assertThat(cache.glob(list("foo/first.js"), list("foo/first.js"), false)).isEmpty(); + assertThat(cache.glob(list("foo/first.js"), list("*/first.js"), false)).isEmpty(); + assertThat(cache.glob(list("foo/first.js"), list("*/*"), false)).isEmpty(); + } + private void assertEmpty(Collection<?> glob) { assertThat(glob).isEmpty(); } |